public void Notification(string[] to, string body) { MailConfiguration mailConfiguration = mailConfigurationLazy.Value; List <MailMessage> msgList = GetSendMessageList(mailConfiguration.Account, mailConfiguration.Name, to, "待办通知", body); foreach (var message in msgList) { smtpClientLazy.Value.Send(message); } }
static MailService() { MailConfiguration mailConfiguration = mailConfigurationLazy.Value; if (mailConfiguration != null) { SmtpClient _smtp = smtpClientLazy.Value; _smtp.Host = mailConfiguration.Host; _smtp.Port = mailConfiguration.Port; _smtp.DeliveryMethod = SmtpDeliveryMethod.Network; _smtp.EnableSsl = mailConfiguration.EnableSsl == 1; _smtp.UseDefaultCredentials = true; _smtp.Credentials = new NetworkCredential(mailConfiguration.Account, mailConfiguration.Password); } }
public void Notification(string[] to, string body) { MailConfiguration mailConfiguration = mailConfigurationLazy.Value; List <MailMessage> msgList = GetSendMessageList(mailConfiguration.Account, mailConfiguration.Name, to, "待办通知", body); foreach (var message in msgList) { try { smtpClientLazy.Value.Send(message); } catch (Exception ex) { logging.Error(ex.ToString()); } } }