System.Net.Mail - Unable to read data from the transport connection
Posted on 2006-07-05
I'm migrating an app to ASP.NET 2.0 and I can't get any email out. I've tried a few different samples of sending email via System.Net.Mail, and tried setting the Web.Config to -
<network host="192.168.250.104" password="" userName="" />
but I always get the same error -
Unable to read data from the transport connection: net_io_connectionclosed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
Line 117: client.Send(message);
Line 118: }
The code is
public static void SimpleMailTest()
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new MailAddress("email@example.com");
message.Subject = "This is my subject";
message.Body = "This is the content";
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("192.168.250.104", 25);
The IIS SMTP service always worked fine with CDONTS and System.Web.Mail. Any help much appreciated.