Untitled
unknown
plain_text
a year ago
1.3 kB
2
Indexable
Never
try { MailMessage newMail = new MailMessage(); // use the Gmail SMTP Host SmtpClient client = new SmtpClient("smtp.gmail.com", 587); // Follow the RFS 5321 Email Standard newMail.From = new MailAddress(senderEmail, senderName); newMail.To.Add(recipientEmail);// declare the email subject newMail.Subject = "Your report in process"; // use HTML for the email body newMail.IsBodyHtml = true; newMail.Body = $"<h4> {emailText} </h4>"; // enable SSL for encryption across channels client.EnableSsl = true; // Port 465 for SSL communication client.Port = 25; // Provide authentication information with Gmail SMTP server to authenticate your sender account client.Credentials = new System.Net.NetworkCredential(senderEmail, senderPassword); client.Send(newMail); // Send the constructed mail Console.WriteLine("Email Sent"); } catch (Exception ex) { Console.WriteLine("Error -" +ex);