Sending an email over Ssl is really simply with System.Net.Mail. In fact, all
you need to do is set the .EnableSsl property on the SmtpClient property to
Below you will find an example of of SMTP over SSL.
Note: Due to what I believe is a bug in System.Net.Mail you *cannot* use
SSL and Credentials (username/password) at the same time. I was never able to
get that to work. I always got an exception from the remote mail server. I
believe it has to do with the steps System.Net.Mail takes to initiate the SSL
session and SMTP authentication.
[ C# ]
static void SSL()
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("email@example.com");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//Port 587 is another SMTP port
SmtpClient smtp = new SmtpClient("127.0.01", 587);
smtp.EnableSsl = true;
[ VB.NET ]
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("firstname.lastname@example.org")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."
'Port 587 is another SMTP port
Dim smtp As New SmtpClient("127.0.0.1", 587)
smtp.EnableSsl = True