Sending Mails Using Code

Posted: October 7, 2008 in Mail

protected void SendEmail(string byWhom, string from, string requestNo)
{
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); message.From = new System.Net.Mail.MailAddress(from);
message.Subject = “Client Request : ” + requestNo;
message.To.Add(abc@xyz.com);
StringBuilder strBuilder = new StringBuilder();
strBuilder.Append(“”);
strBuilder.Append(“”);
strBuilder.Append(“”);
strBuilder.Append(“Hi Sir/Madam,
A new request has been created. The request number of the request is : ” + this.lblRequestNo.Text + “. Please navigate to the page ‘http://dscp018176:200/Lists/ACBS%20Client%20Request/AllItems.aspx’ and do the needful.
Thanks,
” + this.util.GetLoggedInUserName());

strBuilder.Append(“”);
strBuilder.Append(“”);
message.IsBodyHtml = true;
message.Body = strBuilder.ToString();

System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(ConfigurationManager.AppSettings[“MailServer”]);
client.Send(message);}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s