Created
September 7, 2012 07:35
-
-
Save gabrielgreen/3664123 to your computer and use it in GitHub Desktop.
EmailUtility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Mail; | |
public static class EmailUtility | |
{ | |
public static void SendEmail(string from, string[] to, string[] cc, string subject, string body, bool isHTML) | |
{ | |
MailMessage message = new MailMessage | |
{ | |
Subject = subject, | |
Body = body, | |
IsBodyHtml = isHTML, | |
From = new MailAddress(from), | |
}; | |
Array.ForEach(to, c => message.To.Add(c)); | |
Array.ForEach(cc, c => message.CC.Add(c)); | |
SmtpClient SmtpMailer = new SmtpClient | |
{ | |
Host = "smtp.gmail.com", | |
Port = 587, | |
Timeout = 50000, | |
EnableSsl = true | |
}; | |
SmtpMailer.Credentials = new System.Net.NetworkCredential("[email protected]", "yourgmailpassword"); | |
SmtpMailer.Send(message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment