Monday, January 19, 2009

C#: Send Mail

This code shows how to send a mail using the classes of System.Net Namespace

using System.Net.Mail;
public bool SendMail()
{
MailMessage mailMessage = new MailMessage(MailFrom, MailTo);

mailMessage.Subject = MailSubject;

mailMessage.Body = MailMessage;

mailMessage.IsBodyHtml = true;

mailMessage.Priority = MailPriority.Normal;

SmtpClient smtpClient = new SmtpClient();

smtpClient.Send(mailMessage);

return true;
}

No comments:

Post a Comment