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

How to count the number of objects present in a web page? How to count the number of radio buttons in a web page?

0 Answers   HCL,


What is a web farm?

0 Answers  


Why is global asax is used for?

0 Answers  


How would you turn off cookies on one page of your website?

0 Answers  


What is httpresponse?

0 Answers  






What is Assert Method ?

2 Answers  


what is page life cycle state management postback cross page postback types of feilds in gridview gridview events their life cycle cte in sql diff truncate and delete paging concepts in gridview diff bet gridview datalist and repeater what new operations in sql 2005 compared to earlier you get

1 Answers   e4e,


How do you declare static variable? What is its lifetime?

0 Answers  


One application have three forms for registration .submit button is at third form.after filling three forms only u have to click submit button.After clicking the submit button all the values in first,second& third form saved on sql server.how to handle this situation .

6 Answers   TCS,


What is ViewState? What does the "EnableViewState" property do? Why would I want it on or off?

0 Answers  


What are type/key pairs in client script registration? Can there be 2 scripts with the same type/key pair name?

0 Answers  


Name and describe some HTTP Status Codes and what they express to the requesting client ?

1 Answers  


Categories