Wednesday, April 19, 2006

Sending Mail from .Net application

This is a method which can be used for sending mails from Dot Net applications


private void SendMail(string FromAddress, string ToAddress, string BCCAddress, string Subject, string Message)
{
System.Web.Mail.MailMessage oMail = new System.Web.Mail.MailMessage();

oMail.To = ToAddress;
oMail.Bcc = BCCAddress;
oMail.From = FromAddress;

oMail.Subject = Subject;
oMail.Body = Message;

oMail.BodyEncoding = System.Text.Encoding.UTF8;
System.Web.Mail.SmtpMail.SmtpServer = "smtp";
System.Web.Mail.SmtpMail.Send(oMail);
}

0 Comments:

Post a Comment

<< Home