Ejemplo n.º 1
0
        /// <summary>
        /// SendEmail
        /// </summary>
        /// <param name="mailMessage"></param>
        public void SendEmail(MailMessage mailMessage)
        {
            try
            {
                SetupManager       setupManager       = new SetupManager();
                EmailConfiguration emailConfiguration = setupManager.GetEmailConfiguration();

                SmtpClient smtp = new SmtpClient();
                smtp.UseDefaultCredentials = emailConfiguration.RequireCredentials;

                if (emailConfiguration.RequireCredentials)
                {
                    smtp.Credentials = new NetworkCredential(emailConfiguration.Username, emailConfiguration.Password);
                }

                smtp.Host = emailConfiguration.HostName;

                smtp.Port = emailConfiguration.PortNumber;

                smtp.EnableSsl = emailConfiguration.EnableSSL;

                mailMessage.From = new MailAddress(emailConfiguration.DefaultSenderEmail);
                Email email = new Email(smtp);
                email.SendEmail(mailMessage);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// SendEmail
        /// </summary>
        /// <param name="mailMessage"></param>
        public void SendEmail(MailMessage mailMessage)
        {
            try
            {
                SetupManager setupManager = new SetupManager();
                EmailConfiguration emailConfiguration = setupManager.GetEmailConfiguration();

                SmtpClient smtp = new SmtpClient();
                smtp.UseDefaultCredentials = emailConfiguration.RequireCredentials;

                if (emailConfiguration.RequireCredentials)
                {
                    smtp.Credentials = new NetworkCredential(emailConfiguration.Username, emailConfiguration.Password);
                }

                smtp.Host = emailConfiguration.HostName;

                smtp.Port = emailConfiguration.PortNumber;

                smtp.EnableSsl = emailConfiguration.EnableSSL;

                mailMessage.From = new MailAddress(emailConfiguration.DefaultSenderEmail);
                Email email = new Email(smtp);
                email.SendEmail(mailMessage);
            }
            catch(Exception ex)
            {
                log.Error(ex.Message,ex);
            }
        }