How to send Email using Gmail Server

November 2nd, 2012 | Posted by Nitesh Luharuka in .Net | General

I have seen many developers asking this questions and hence thought of writing this brief post. This post describes the code to send an email in C# using Gmail as mail server.

SmtpClient smtpServer = new SmtpClient("");
smtpServer.Port = 587;
smtpServer.Credentials = new NetworkCredential("", "PASSWORD");
smtpServer.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("", "USER NAME");
mail.IsBodyHtml = true;
mail.To.Add(""); //Sender's Email
mail.Cc.Add(""); //Email address of person to be put in Cc
mail.Bcc.Add(""); //Email address of person to be put in BCc
      mail.Subject = "Test Subject";
      String body = "Test Email using Gmail Server";
      mail.Body = body;
catch (Exception)

Hope you like it. Thanks for reading!

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

8 Responses

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Support us!

If you like this site please help and make click on any of these buttons!