Digital Colony!

Sending Email in ASP.NET 2.0 (C#)

Here is the C# version of Sending Email in ASP.NET 2.0 (VB.NET).
using System.Net.Mail;
The code snippet demonstrates Larry King emailing Oprah.
MailMessage Message = new MailMessage();
SmtpClient Smtp = new SmtpClient();
// Build message
Message.From = new MailAddress("larryking@cnn.com", "Larry King");
Message.To.Add(new MailAddress("oprah@oprah.com", "Oprah"));
Message.IsBodyHtml = false;
Message.Subject = "Come on My Show Soon";
Message.Body = "Please be a guest on my show. - Larry";
// Send Message
// each web host is different 
// (adjust next 2 lines accordingly)
Smtp.Host = "localhost";
Smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
Smtp.Send(Message);

Labels: , ,

AddThis Social Bookmark Button

0 Comments:

 

Post a Comment

 

Digital Colony Copyright © 1999-2008 XHTML   508
This site uses Blogger, which is not 100% XHTML compliant.
Try...Catch Disclaimer: For brevity many examples do not include error handling. That is your responsibility.