SmtpClient and net_io_connectionclosed

I've been working on a console application that needs to send emails to customers as part of a business process.

After only 5 emails being sent, the sixth email caused the following exception  .... "Unable to read data from the transport connection: net_io_connectionclosed"

What surfaced after some 'googling' was this article SmtpClient does not gracefully close the underlying TCP/IP connection over on Microsoft Connect.

Basically, the workaround is to set SmtpClient.ServicePoint.MaxTimeout = 1 in your code.

Now, the application sends out those emails without problems.

Hope that helps!

3 Comments

Comments have been disabled for this content.