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.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

I get a database timeout expired error on my ASP.NET application. What can I do?

I get the following error when my ASP.NET application connects to the MS SQL server:...

How do I get my ASP.net application to display non-English language

ASP.net allows the developer to encode the page using character sets other than unicode.  If your...

I get a configuration error when I execute my application in a subdirectory. How do I resolve this?

This error may occur if the application is being run out of a subfolder and the subfolder is not...

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...

After I configure the custom error setting in the control panel, I still get the generic error page?

Custom error setting is a web server setting that sets your website Error Pages, but you can...