System. net. Mail sends an email

Source: Internet
Author: User
Tags all mail mailmessage smtpclient

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 ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.