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

}

  • 7 istifadəçi bunu faydalı hesab edir
Bu cavab sizə kömək etdi?

Uyğun məqalələr

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