Friday, August 2, 2013

IDisposable with SmtpClient?

I found this which suggests that within System.Net.Mail in C# 4.0 SmtpClient implements IDisposable and that one may write code like so:

using(SmtpClient smtp = new SmtpClient())
{
   smtp.Host = "emailservername";
   smtp.Port = 25;
   smtp.UseDefaultCredentials = true;
   smtp.Send(mail)
}

 
 

There is no IDisposable-flavored SmtpClient in 3.5 stuff. That makes me cranky. The same stackoverflow post suggests that a lot of flakiness will just go away if one is in fourpointohland. I found this by Googling "Unable to read data from the transport connection: net_io_connectionclosed." which is my particular error.

No comments:

Post a Comment