Sending E-Mail with .Net and GMail

This was so easy I just had to share.

// Create MailMessage Object
MailMessage Msg = new MailMessage(email,"",subject,message);
// Setup SmtpClient to point to GMail SMTP server
SmtpClient client = new SmtpClient("",587);
// set your credentials
client.Credentials = new System.Net.NetworkCredential("<SOMEEMAILADDRESS>", "XXXXXXX");
// turn on SSL
client.EnableSsl = true;
// send it!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.