public void SendEmail(string toAddress, string fromAddress, string subject, string htmlContent)
        {
            string environment = ConfigurationManager.AppSettings["environment"];

            if (environment != "Production")
            {
                toAddress = SupportEmail;
            }

            MailMessage objMail = new MailMessage();

            objMail.To.Add(toAddress);
            objMail.From       = new MailAddress(fromAddress);
            objMail.Subject    = subject;
            objMail.IsBodyHtml = true;
            objMail.Body       = htmlContent;

            string gmailUserName = ConfigurationManager.AppSettings["gmailUserName"];

            if (string.IsNullOrWhiteSpace(gmailUserName) == false)
            {
                var GmailSmtpClient = new GmailSmtpClient();
                GmailSmtpClient.Send(objMail);
            }
        }
Exemple #2
0
 public async Task SendMessageAsync(MailMessage message)
 {
     // We don't send mail very often, so we don't need to keep the SmtpClient instance around.
     using (GmailSmtpClient client = new GmailSmtpClient(Info.Address, Info.Password))
     {
         await client.SendAsync(message);
     }
 }