What a WEIRD solution ?!? - Ed's Blog
in

dotnet.org.za

South African .NET Developer Portal

Ed's Blog

Object reference not set to an instance of an object

What a WEIRD solution ?!?

I had trouble sending mail using the built in .NET stuff (which of course is only a wrapper for CDONTS). I got the "Could not access 'CDO.Message' object" error, with an innerException of “Could not connect to the underlying transport”.

Found this site on the internet that has some very usefull info. The solution to my problem was this

Old Code(cause the error):
SmtpMail.SmtpServer = “127.0.0.1“;

New Code(works 100%):
SmtpMail.SmtpServer.Insert(0,“127.0.0.1“);

'Insert' if of course the string method that inserts a string starting at a certain index. This was so weird that I checked out the dissasembly for the SmtpServer property, its a straight assign as in

_smtpServer = value;

none of the other methods in the class does any manipulation on the string. How weird is that !

Published Oct 08 2004, 09:03 AM by eduard
Filed under:

Comments

 

Jerrie Pelser said:

Or you could just accept the fact that the built-in SMTP class sucks and start using OpenSMTP.NET (http://sourceforge.net/projects/opensmtp-net/). I had endless hassles with the standard .NET Framework SMTP class, but since switching to OpenSMTP I have hade none.
October 8, 2004 10:09 AM
 

bryanallott said:

Not that strange a solution, actually :)

MYTH: SmtpMail.SmtpServer.Insert(0,"127.0.0.1") Actually Does Something
http://blogs.msdn.com/mstehle/archive/2005/11/23/496418.aspx

explains things quite logically..
June 16, 2006 11:43 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Powered by Community Server (Commercial Edition), by Telligent Systems