"Object reference not set to an instance of an object" error when trying to create object of System.Net.Mail.MailMessage

A few days ago I ran into an interesting problem. A customer who was trying to send a mail using System.Net.Mail was getting the error "Object reference not set to an instance of an object" when trying to create a Instance of the MailMessage class. Code that was failing MailMessage message = new MailMessage() The…

0

System.Net.Mail unable to Authenticate against some third party SMTP Servers

I recently ran into an issue where one of my customer was unable to send mail using System.Net.Mail(.Net 2.0), we always got the "Authentication failed" error. We tried sending mail using Microsoft CDO for Windows 2000 Library(Cdosys) and System.Web.Mail and the mails went just fine. if Cdosys works System.Web.Mail(SWM) would normally work because SWM is…

2

How to force System.Net.Mail to use AUTH LOGIN instead of AUTH gssapi

When we send a mail out using System.Net.mail, It sends out a EHLO command, It then parses out the response to create a list of the Authentication mechanism that are supported by the SMTP Server. It then loops through the internal Authentication mechanisms which are listed below: -SmtpNegotiateAuthenticationModule -SmtpNTLMAuthenticationModule -SmtpDigestAuthenticationModule -SmtpLoginAuthenticationModule Then it compared each…

2