How did I send email from ASP.net ?

You have to use System.Web.Mail namespace
Below is the code snippets :

using System.Web.Mail;

MailMessage myemail = new MailMessage();
myemail.From = "hhh@hhh.com"
myemail.To = bbb@bbb.com;
myemail.Subject="Testing";
myemail.Body="Testing";
myemail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
myemail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "myusername";
myemail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "mypass";
try
{
            System.Web.Mail.SmtpMail.SmtpServer= "mail.yourdomain.com"
            System.Web.Mail.SmtpMail.Send(myemail);
            Response.Write("send successfully");
}
catch(Exception Error)
{
           Response.Write("Failed");
}

Replace yourdomain.com with your domain name.
Replace user name with your mail username (full address)
Replace password with your email password.

Remember, you have to authenticate yourself before you can send email from our server or else the mail will not be delivered.

Was this answer helpful?

 Print this Article

Also Read

I am using ASP.NET and Internet Explorer Web Controls and it does not work when I open the page. What is wrong?

For Internet Explorer Web Controls to work properly you need to have the required HTML...

How do I configure my ASP.NET 3.5 Framework?

To configure your ASP.NET3.5 Framework, it is pretty easy via our control panel. For Old In...

Why can I still access my ASP.NET pages even though I disabled anonymous access to my directory?

After disabling anonymous access in the permission manager in the control panel, ASP.net pages...

I receive an error when trying to access an ASP.NET page within a subweb. What do I do?

The ASPNet (user as which ASP.NET runs) user permission does not inherit into the subweb....

I get an error 'A potentially dangerous Request.Form value was detected from the client ' when I hit submit on my ASP.NET Webform. What can I do?

This error is caused by a newly introduced feature of .NET Framework 1.1, called "Request...