Sending Email

Configure the web.config file
<mailSettings >
<smtp from="nratdot4prodotcom">
<network host="smtp.dot4pro.com" />
</smtp>
</mailSettings>

Send the mail

Create an instance of SmtpClient object and send mail.

MailMessage message = new MailMessage();
message.From = new MailAddress("senderatdot4pro.com");
message.To.Add(new  MailAddress("recipient1atdot4pro.com"));
message.To.Add(new  MailAddress("recipient2atdot4pro.com"));
message.To.Add(new  MailAddress("first1atgmaildotcom"));
message.CC.Add(new MailAddress("sendtoatgmaildotcom"));
message.Subject = "This is my subject";
message.Body = "This is the body. can be html body";
SmtpClient client = new SmtpClient();
client.Send(message);

Hope this helps to minimize the code while sending mails.

, , ,

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Share to Facebook Share to Twitter Stumble It Share on Tumblr Digg More...