SMTP Authentication in ASP.NET

Hi, I had faced a problem when sending mails from ASP.NET using .NET 1.0. My Exchange server needs authentication to send mails. Later found that .NET 1.0 doenst support authencation with an SMTP server. I had to switch over to .NET 1.1 to send mails. All which is required to add a few lines of code for authentication.

//This is a usual code
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
msg.Subject = “Test Subject”;
msg.Body = “Sample Body Message”;
msg.From =;
msg.To =;
System.Web.Mail.SmtpMail.SmtpServer = “EXCHANGESERVER”;
System.Web.Mail.SmtpMail.Send( msg );

//Add this line of code for authentication.
where the 2 specifies NTLM, 1 for basic, 0 for none.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s