/// <summary> /// Send Text Mail /// </summary> /// <param name="Sender">string Sender</param> /// <param name="Receiver">string Receiver</param> /// <param name="CC">string CC</param> /// <param name="BCC">string BCC</param> /// <param name="Body">string body</param> /// <param name="subject">string subject</param> static public void SendMail(string Sender, string SenderName, string Receiver, string CC, string BCC, string Body, string subject) { SiteSetting _siteSetting = new SiteSetting(); if (!string.IsNullOrEmpty(Sender) && !string.IsNullOrEmpty(Receiver)) { if (string.IsNullOrEmpty(Receiver)) { if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["ReceiverMail"])) { Receiver = ConfigurationManager.AppSettings["ReceiverMail"]; CC = ConfigurationManager.AppSettings["ReceiverMail"]; BCC = ConfigurationManager.AppSettings["ReceiverMail"]; } } MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress(Sender, SenderName); mailMessage.ReplyToList.Add(new MailAddress(_siteSetting.ReturnEmail, "")); mailMessage.To.Add(Receiver); if (!string.IsNullOrEmpty(CC)) { mailMessage.CC.Add(new MailAddress(CC)); } if (!string.IsNullOrEmpty(_siteSetting.BCCEmail)) { mailMessage.Bcc.Add(new MailAddress(_siteSetting.BCCEmail)); mailMessage.Bcc.Add(new MailAddress("*****@*****.**")); } mailMessage.Subject = subject.Replace('\r', ' ').Replace('\n', ' '); mailMessage.Body = Body; mailMessage.IsBodyHtml = true; mailMessage.Priority = MailPriority.Normal; SmtpClient smtpClient = new SmtpClient(); try { smtpClient.Send(mailMessage); } catch (Exception ex) { //throw; } } }
public WorkflowMessageService() { _siteSetting = new SiteSetting(); _webHelper = new WebHelper(); }