If for some reason you need to send mail via the Google GMail SMTP server, here is how you do it. Keep in mind that the connection has to be secured and it's using an unusual port. If you have a firewall, you may want to do some re-configuration.

 

   1: int port = 587;
   2: string userName = "myemail@gmail.com";
   3: string password = "password";
   4:  
   5: try
   6: {
   7:     MailMessage message = new MailMessage();
   8:  
   9:     message.From = new MailAddress("myemail@gmail.com", "Rydal Williams");
  10:     message.To.Add(new MailAddress("anotheremail@hotmail.com", "Rydal Williams"));
  11:     message.Subject = "Test email via GMail smtp server.";
  12:     message.Body = "Put email message here.";
  13:  
  14:     SmtpClient smtp = new SmtpClient("smtp.gmail.com", port);
  15:     smtp.Credentials = new System.Net.NetworkCredential(userName, password);
  16:     smtp.EnableSsl = true;
  17:     smtp.Send(message);
  18:  
  19:     Console.WriteLine("Message sent successfully!");
  20: }
  21: catch (Exception ex)
  22: {
  23:     Console.WriteLine("Failed to send message because " + ex.Message);
  24: }
  25: finally
  26: {
  27:     Console.ReadKey();
  28: }