3/18/2014

Send E-Mail ASP.Net C# Coding

You can send a mail from C# coding in the button click event.

Here i have considered gmail as the E-Mail Gateway you can choice your own gateway and give the gateways setting and port settings here.

var myMailMessage = new System.Net.Mail.MailMessage();
myMailMessage.From = new System.Net.Mail.MailAddress("serveremail@gmail.com"); myMailMessage.To.Add("****Recipient Mail ID*****"); 
myMailMessage.CC.Add("****Recipient CC Mail ID*****"); 
myMailMessage.Subject = "Your Subject";
myMailMessage.Body = "Welcome to our website"; 
var smtpServer = new System.Net.Mail.SmtpClient("smtp.gmail.com"); 
smtpServer.Port = 587; 
smtpServer.Credentials = new System.Net.NetworkCredential("Fromemailid here", "****password***"); smtpServer.EnableSsl = true; smtpServer.Send(myMailMessage);

E-Mail sending with the help of html format will be updated soon.