private static bool SingleSend(EmailInformations from, EmailInformations to, MailMessage message)
        {
            try
            {
                var fromAddress = new MailAddress(from.Email, from.Name);
                var toAddress   = new MailAddress(to.Email, to.Name);
                var config      = ReportHelper.Configuration;
                var smtp        = new SmtpClient
                {
                    Host                  = config.SmtpHost,
                    Port                  = config.SmtpPort,
                    EnableSsl             = config.EnableSsl,
                    DeliveryMethod        = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Credentials           = new NetworkCredential(from.Email.Split('@').First(), from.Password),
                    Timeout               = 10000
                };

                using (smtp)
                {
                    message.From = fromAddress;
                    message.To.Add(toAddress);
                    smtp.Send(message);
                }
            }
            catch (Exception ex)
            {
                InternalLogs.Exception(ex, "Failure in SingleSend method!");
                return(false);
            }
            return(true);
        }
Beispiel #2
0
 public static MailAddress ToMailAddress(this EmailInformations address)
 {
     return(new MailAddress(address.Email, address.Name));
 }