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

How do I connect my ASP.net application to MySQL database?

In general, 2 different methods can be used to connect an ASP.net application to MySQL database....

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 couldn't see any Error Message on my ASPX Page? What should I do?

This happens because of the web.config custom Error page is set to RemoteOnly or On. If you...

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