Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 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);
 }