// Put the properties of the email including "to", "cc", "from", "subject" and "email body" private MailMessage ConstructEmailMessage(EmailSendConfigure emailConfig, EmailContent content) { MailMessage msg = new System.Net.Mail.MailMessage(); foreach (string to in emailConfig.TOs) { if (!string.IsNullOrEmpty(to)) { msg.To.Add(to); } } foreach (string cc in emailConfig.CCs) { if (!string.IsNullOrEmpty(cc)) { msg.CC.Add(cc); } } msg.From = new MailAddress(emailConfig.From, emailConfig.FromDisplayName, System.Text.Encoding.UTF8); msg.IsBodyHtml = content.IsHtml; msg.Body = content.Content; msg.Priority = emailConfig.Priority; msg.Subject = emailConfig.Subject; msg.BodyEncoding = System.Text.Encoding.UTF8; msg.SubjectEncoding = System.Text.Encoding.UTF8; if (content.AttachFileName != null) { Attachment data = new Attachment(content.AttachFileName, MediaTypeNames.Application.Zip); msg.Attachments.Add(data); } return(msg); }
public void SendMail(EmailSendConfigure emailConfig, EmailContent content) { MailMessage msg = ConstructEmailMessage(emailConfig, content); Send(msg, emailConfig); }