Aug 10, 2011

How to use Send Email Concepts in Asp.net application

The MailMessage and SMTP are classes defined in the .NET Framework Class Library's System.Web.Mail namespace. It is 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 to relay message through the local SMTP Service.


Example:
        MailMessage message = new MailMessage ();
        message.From = <from@testmail.com>;
        message.To = <to@testmail.com>;
        message.Subject = "Welcome to Asp.net Example";
        message.Body = "Free Subscribe to the Asp.net Example";
        SmtpMail.SmtpServer = "localhost";
        SmtpMail.Send (message);

No comments:

Post a Comment