Thursday, April 11, 2013

Solved! How to send email using C# in .Net , Simple Code

Hi,

These settings are using google email. You may configure it accordingly.

using System.Net;
using System.Net.Mail;

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.google.com");

mail.From = new MailAddress("from address");
mail.To.Add("to address");
mail.Subject = "Email Subject";
mail.Body = "Email Body";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("from address", "from address password");
SmtpServer.EnableSsl = false;
SmtpServer.Send(mail);

No comments:

Post a Comment