Click here to Skip to main content
15,033,650 members

Comments by Prnda76 (Top 1 by date)

Prnda76 23-Feb-13 15:59pm View
   
There is EnableSsl property on the SmtpClient class. So in other words, to send mail via Gmail you can use:

var client = new SmtpClient
{
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential("yourGmailUsername", "yourGmailPassword"),
Host = "smtp.gmail.com"
};
var message = new MailMessage
{
// Setup your MailMessage instance here...
}
client.Send(message);