Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool SendAnnouncementCreationNotification(string toEmail, string announcementTitle, string announcementDescription)
- {
- string from = ConfigurationManager.AppSettings["ContactEmailAddress"].ToString();
- string subject = "AAID - New Announcement";
- string smtpClient = ConfigurationManager.AppSettings["SmtpClient"].ToString();
- string smtpUser = ConfigurationManager.AppSettings["SmtpUser"].ToString();
- string smtpPassword = ConfigurationManager.AppSettings["SmtpPassword"].ToString();
- int port = 0;
- int.TryParse(ConfigurationManager.AppSettings["SmtpPort"], out port);
- StringBuilder mailBody = new StringBuilder();
- mailBody.AppendFormat("<p>Hello!</p>");
- mailBody.AppendFormat("<br />");
- mailBody.AppendFormat(string.Format("<p>A new announcement - {0} - has been created", announcementTitle));
- mailBody.AppendFormat("<p>" + announcementDescription + "</p>");
- mailBody.AppendFormat("<br />");
- mailBody.AppendFormat("<p>With all best wishes,</p>");
- mailBody.AppendFormat("<p>The AAID team</p>");
- string body = mailBody.ToString();
- MailMessage email = new MailMessage(from, toEmail, subject, body);
- email.IsBodyHtml = true;
- SmtpClient client = new SmtpClient(smtpClient, port);
- client.UseDefaultCredentials = false;
- client.Credentials = new NetworkCredential(smtpUser, smtpPassword);
- client.EnableSsl = enabledSSL;
- try
- {
- client.Send(email);
- return true;
- }
- catch (Exception ex)
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement