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

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

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

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

ASP.NET Validation is not working on your server.

...