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.

 
  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

I get an error 'Server.CreateObject Failed' when I try to use CDONTs. What can I do?

CDONTs is no longer supported on Windows 2003 server.  Microsoft introduced CDO back several...

Do you allow custom COM components?

Yes, we do allow Custom Components and we have to charge setup fee for your COM Components...

ASP to MSSQL connection

Before you can access your MS-SQL Server database from your ASP code , you need to connect to it...

How do I send email from ASP using SMTP Authentication?

Please note that our mail server is configured with Authentication. Below is the code snippet...

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