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



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

Answer / kumar saurabh

MailMessage message = new MailMessage ();
message.From = <email>;
message.To = <email>;
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.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

Can session variables be accessed from code-behind?

2 Answers   Microsoft, RMS,


Which methods validate all the controls on a page?

0 Answers  


Suppose you want an asp.net function (client side) executed on the mouseover event of a button. Where do you add an event handler?

0 Answers  


What is the purpose of App_Code folder in ASP.NET? Why we this?

0 Answers   Sans Pareil IT Services,


What is the concepts of globalization and localization in .net?

0 Answers  


Define cookie.

0 Answers  


You need to retrieve data from a Microsoft SQL Server 2000. Currently you are using an oleDbConnection object to connect to the database server. You need to be able to retrieve the data from the database server in XML format. Which approach would be the most efficient? Select all that apply. Each answer constitutes part of the whole answer. a) Change to the SQL .NET provider. b) Use the ExecuteXmlReader() method of the xxxCommand object c) Use the DOM to create the XML document. d) Use the XmlDocument.Load() method to create the XML Document.

1 Answers   Syntax Softtech,


What are navigation controls? How many navigation controls are there in ASP.NET 4.0?

0 Answers   UGC Corporation,


What does assemblyinfo.cs file consist of?

2 Answers   Accenture, HCL,


What is Web Application?

2 Answers   HCL,


how to integrate Language conversion, without asking the enduser to download font, it should auto integrate

1 Answers  


With example & diagram explain AutoPostBack.

2 Answers  


Categories