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

Define page fragment caching?

0 Answers  


After capturing the SelectIndexChanged event for a ListBox Control, you find that the event handler doesn?t execute. What could be the problem be? a) The AutoEventWireup attribute is set to False b) The AutomaticPostBack attribute is set to False c) The codebehind module is not properly compiled d) The ListBox must be defined WithEvents.

2 Answers   Syntax Softtech,


Can One website be made using two different languages like c#,vb.net etc......

4 Answers   ABC,


Hi, I am a fresher. i have a problem related to DataGrid . i have a data grid and i have to place a dropdown in the datagrid.and i have to retrieve the values from the database (sqlserver).please tell me any idea about the code.

1 Answers   Lambent,


Who can consume WebAPI?

0 Answers  






What is odata in web api?

0 Answers  


If we write return statement in finally block will it works fine or throws any error?

1 Answers   Patni,


How can we Validate a Controls in ASP.NET page using JavaScript?

0 Answers   QuestPond,


Is asp net front end or backend?

0 Answers  


Explain in what order a destructors is called.

0 Answers  


How would one do a deep copy in .NET?

6 Answers   TCS,


Name the namespace which is used by ado.net?

0 Answers  


Categories