I recently upgraded my computer at work and since then I cannot send email from applications running on my local computer. This worked before the upgrade. There is obviously some setting that needs to be tweaked but I don't know what it is. Below is a very simple example of something that fails. When it gets to the "theClient.Send(theEmailTo
Send)" it gets an exception and the message is: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
When i run this same code on a server as part of a Web application (with "theClient.Host" set to a proper IP address) it works fine. I've always been able to change the host to "localhost" for my testing, but now it does not work.
Thanks in advance.
System.Net.Mail.MailMessage theEmailToSend = new System.Net.Mail.MailMessage();
System.Net.Mail.MailAddress theRecipient = new System.Net.Mail.MailAddress("TimAttaway@mchapusa.com", "Tim Attaway");
System.Net.Mail.MailAddress FromAddress = new System.Net.Mail.MailAddress("TimAttaway@mchapusa.com", "Tim Attaway");
theEmailToSend.From = FromAddress;
theEmailToSend.Body = "This is a simple email.";
theEmailToSend.IsBodyHtml = false;
theEmailToSend.Subject = "Email Test";
System.Net.Mail.SmtpClient theClient = new System.Net.Mail.SmtpClient();
theClient.Host = "localhost";
theClient.Port = 25;