[ASP.NET C#]send mail message


Add reference dll for System.Net and System.Net.Mail to solution explorer.
Then You can use the following method helps to send mail message

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

public void MailSend()
string msgFrom = “test@abc.com“, msgTo = “test2@abc.com“, subject = “Hi", msgContent = “Good Morning";
MailMessage mMessage = new MailMessage();
MailAddress from = new MailAddress(msgFrom);
mMessage.From = from;

MailAddress messageTo = new MailAddress(msgTo);

mMessage.Subject = subject;
mMessage.Body = msgContent;

SmtpClient theClient = new SmtpClient(“");  //smtp server name
NetworkCredential authenticationInfo = new NetworkCredential(“","");  // smtp server userid & password
theClient.Credentials = authenticationInfo;
authenticationInfo = null;
theClient = null;