Mono, C# Sending mail through gmail

Hello I’m back at blog posting after some busy time!

I know this example is nothing to do with mono but since I use mono these days this example also develop this in SharpDevelop+Mono+gtk#, My aim is simple just send a mail through my gmail account…

Let’s code than:

using System;
using System.Net.Mail;
using System.Collections.Generic;
using System.Text;
using Gtk;
using GtkSharp;
using GLib;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
namespace KentSoft
class  printTest : Window
public  printTest()
: base("Kent_Calisma")

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("");
mail.From = new MailAddress("");
mail.Subject = "TEST";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("gmailusername without", "gmailpassword");
SmtpServer.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
catch(Exception e){
public static void Main()
new printTest();


mailoutputThats all folks for sending mail from C# using gmail!
Become a Friend of GNOME
kick it on