ASP.Net Programming Question:

Download Job Interview Questions and Answers PDF

How do I send e-mail from an ASP.NET application?

ASP.Net Interview Question
ASP.Net Interview Question

Answer:

MailMessage message = new MailMessage ();
message.From = ;
message.To = ;
message.Subject = "Scheduled Power Outage";
message.Body = "Our servers will be down tonight.";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send (message);

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.

Download ASP.Net Interview Questions And Answers PDF

Previous QuestionNext Question
Is it necessary to lock application state before accessing it?What are VSDISCO files?