public void Send(EmailMessageModel model) { Ensure.That(() => model).IsNotNull(); MailMessage message = new MailMessage(model.Sender, model.Recipient) { Subject = model.Subject, Body = model.Body, IsBodyHtml = true }; try { using (message) { if (Config.OutgoingEmail.Timeout.HasValue) { client.Timeout = Config.OutgoingEmail.Timeout.Value; } client.Send(message); // TODO: SendAsync? } } catch (SmtpException exception) { log.Warn(Error.MailSendError, exception); } }
public void SendEmail(string recipient, string subject, string body) { MailAddress sender = Config.OutgoingEmail.GetAddress(); EmailMessageModel email = new EmailMessageModel(sender, recipient, subject, body); log.Info(Debug.EmailOutgoing.FormatWith(recipient, subject)); emailRepository.Send(email); }