Wednesday, October 15, 2008

How to Send email in ASP.NET using C# through Gmail Outgoing Mail Server


SmtpClient oSmtpClient = new SmtpClient();
oSmtpClient.Host = "smtp.gmail.com"; //The Outgoing mail server
oSmtpClient.Credentials = new NetworkCredential("Your Email", "Your password");
oSmtpClient.Port = 587;
oSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
oSmtpClient.EnableSsl = true;
MailMessage msg = new MailMessage("Email From", "Email To");
msg.Subject = "Subject goes here";
msg.Body = "Body goes here";
oSmtpClient.Send(msg);

Hire Me

Follow me on Facebook

Follow me

Do you find this Blog helpful?

Follow by Email

About Me

My Photo
Expert Senior Software Developer

Microsoft Business Card