Wednesday, August 18, 2010

Sending Emails using Gmail User Account in Asp.Net

To send an email you can use System.Net.MailMessage class.  The following example demonstrates how to send an email using your own Gmail user account.

MailMessage mailMsg = new MailMessage();

mailMsg.From =new MailAddress(;
mailMsg.Subject = "Hai";
mailMsg.Body = "Chumma";
mailMsg.Priority = MailPriority.High;
SmtpClient c = new SmtpClient("",587); // or u can use port 465
NetworkCredential cred = new NetworkCredential("username", "password"); //ur account username and password to authenticate your request.
c.Credentials = cred;
c.EnableSsl = true;
catch (Exception ex)

No comments: