How do I send an email message from my ASP.NET page?



How do I send an email message from my ASP.NET page?..

Answer / Sumeet Bhatnagar

To send an email message from an ASP.NET page, you can use the System.Net.Mail namespace. Here's a simple example:

using System.Net;
using System.Net.Mail;

MailMessage mail = new MailMessage();
SmtpClient Client = new SmtpClient();

mail.From = new MailAddress("yourEmail@example.com");
mail.To.Add("recipientEmail@example.com");
mail.Subject = "Test Email";
mail.Body = "This is a test email sent from ASP.NET.";

Client.Port = 25;
Client.DeliveryMethod = SmtpDeliveryMethod.Network;
Client.UseDefaultCredentials = false;
Client.Host = "smtp.example.com";
Client.EnableSsl = true;
Client.Send(mail);

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

What is simple data binding?

1 Answers  


I have prepared A Dynamic website in asp.net with c# and using Ms Sql server 2005 as backend database.i am facing problem while uploading this site on my FTP address it is not accessing the database.please could u tell me how cn i upload Sqlserver database on the web and what would be the connection string...???? I am using Server=".";initial catalog=databasename;persist security info=false;integrated security=SSPI;...pleas help me... Thanks in Advance..

1 Answers  


What is the good practice to implement validations in aspx page?

1 Answers  


What is view state and how this can be done and was this there in asp?

11 Answers   Accenture, KDOT, Mphasis,


What is active web page?

1 Answers  


Usage of web.config?

2 Answers   Microsoft,


What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState ?

1 Answers  


How would you get asp.net running in apache web servers?

1 Answers  


What is the base class from which web forms are inherited?

1 Answers  


How can you ensure a permanent cookie?

1 Answers  


About writting a query and SP which is better ?

5 Answers   Abacus, Satyam,


What are the different methods that are used during the page load?

1 Answers   Siebel,


Categories