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

How can I send email from ASP.net if SMTP Authentication is required for your mail Server?

Our SMTP Server requires authentication before you can send email, But If your ASP or ASP.net...

ASP.NET Validation is not working on your server.

...

In one of the applications I want to host, there must be a write privilage to ASPNET account so that it will be able to create folders, so is that possible ?

Yes, that is possible. In fact you can set the read and write permission yourself. Our control...

How do I setup custom error for my ASP.net application?

ASP.net has its own built-in error handling. To set up custom error handling for your ASP.net...

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