Send Email using Gmail - C#

Send Email using Gmail - C#

code snippet

c#
using (var client = new SmtpClient{
Credentials = new System.Net.NetworkCredential("username", "password"),
Port = 587, // You can use Port 25 if 587 is blocked 
Host = "smtp.gmail.com"
}){
var mail = new MailMessage();
mail.From = new System.Net.Mail.MailAddress("from@email.com");
mail.To.Add("to@email.com"); 
mail.Subject = "Email Subject";
mail.Body = "Email Body";
mail.IsBodyHtml = false; // or true
try{
    client.Send(mail);
}
catch (Exception){
}

"One today is worth two tomorrows"

Contact me!

Have questions? Feel free to use the form or send me an email with any questions.

I will be responsive to your requests and your questions.