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 script is located on our Web Server, you don't need any SMTP Authentication to send email.

Below is the code examples

using System.Web.Mail;

private void SendEmail(String from,String to,String body,String subject) {
    MailMessage m = new MailMessage();
    m.To = to;
    m.From = from;
    m.Body = body;
    m.Subject = subject;
    
SmtpMail.SmtpServer = "mail.yourdomain.com";
    SmtpMail.Send(m);

}

Was this answer helpful?

 Print this Article

Also Read

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

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

ASP.NET Validation is not working on your server.

...

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

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