Mailmessage mail = new mailmessage ();
Mail. to. Add (New mailaddress ("recipient email address "));
Mail. From = new mailaddress ("send all mail address ");
Mail. Subject = "test ";
Mail. Body = "test body ";
Smtpclient Mailer = new smtpclient ();
Mailer. Host = "smtp.sina.com ";
Mailer. Credentials = new system. net. networkcredential ("the sender's mailbox name", "password ");
Try
{
Mailer. Send (Mail );
This. label1.text = "sent successfully! ";
}
Catch (exception ex)
{
This. label1.text = ex. tostring ();
}
Error:
Exception details: system. net. sockets. socketexception: the software in your host abandons an established connection.
I started to get frustrated with this problem for several days. There is nothing wrong with these lines of code. But the above problem is always prompted. Later, I searched for information online and finally found out.
It turns out to be a problem with anti-virus software. McAfee I use. In its access rules on the console, the default option for sending mails is "prohibit sending a large number of mails". Remove this option and try again.
Finally, we can see the "sent successfully" message for a long time ".