I looked around until something worked without any serious editing, and here's our winner...


   1 public void actuallySendMail ()
2 {
3 // And the winner is from...
4 // http://huseyincakir.wordpress.com/2010/03/11/mono-c-sending-mail-through-gmail/
5 // (fancier lib for sending jive here: http://emailsender.codeplex.com/
6 // and maybe here: http://higlabo.codeplex.com/)
7 MailMessage mail = new MailMessage ();
8 mail.IsBodyHtml = true;
9 SmtpClient SmtpServer = new SmtpClient ("smtp.gmail.com");
10 mail.From = new MailAddress ("yourEmailige@gmail.com");
11 mail.To.Add ("yourEmailige@gmail.com");
12 mail.Subject = "TEST";
13 mail.Body = "This is for <b>testing</b> SMTP mail from GMAIL: "
14 + DateTime.Today.ToString ();
15 SmtpServer.Port = 587;
16 SmtpServer.Credentials =
17 new System.Net.NetworkCredential ("yourEmailige", "yourPasswordige");
18 SmtpServer.EnableSsl = true;
19 ServicePointManager.ServerCertificateValidationCallback =
20 delegate(object s, X509Certificate certificate, X509Chain chain,
21 SslPolicyErrors sslPolicyErrors) {
22 return true;
23 };
24 SmtpServer.Send (mail);
25 }

Labels: , ,