Home > DeveloperSection > Interviews > How do I send e-mail from an ASP.NET application?

Posted on    December-11-2010 12:00 AM

 ASP.Net ASP.Net 
Ratings:
 1 Answer(s)
  1056  View(s)
Rate this:

Amit Singh

Total Post:565

Points:2825
Posted on    December-11-2010 1:00 AM

Sending e-mail in ASP.Net Application
For Example:
MailMessage message = new MailMessage ();
        message.From = aa@abc.com;
        message.To = aa1@xyz.com;
        message.Subject = "Hi, this is the new message";
        message.Body = "hi,this is the new message and one attachements";
        SmtpMail.SmtpServer = "localhost";
        SmtpMail.Send (message);

Note:
MailMessage and SmtpMail are classes defined in the .NET Framework Class Library's  System.Web.Mail namespace. Due to a security change made to ASP.NET just before it shipped,  you need to set SmtpMail's SmtpServer property to "localhost" even though "localhost" is  the default. In addition, you must use the IIS configuration applet to enable localhost  (127.0.0.1) to relay messages through the local SMTP service.

Don't want to miss updates? Please click the below button!

Follow MindStick