我通过这篇文章将我的 Outlook 2010 配置 为从 yahoo.com 发送和接收电子邮件,它运行良好,没有任何问题。
我开发了一个小应用程序来通过我的应用程序发送我的电子邮件,但它给了我错误:
"unable to read data from the transport connection:an exist connection was
forcibly closed by the remote host."
我的代码:
try
{
SmtpClient smtp = new SmtpClient("smtp.mail.yahoo.com", 465);
smtp.UseDefaultCredentials = true;
smtp.EnableSsl = true;
smtp.Credentials = new System.Net.NetworkCredential("myid", "mypass");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mailMessage = new MailMessage();
mailMessage.From = new System.Net.Mail.MailAddress("myid@yahoo.com", "blabla");
mailMessage.To.Add(new System.Net.Mail.MailAddress("xxx@live.com", "xxx@live.com"));
mailMessage.Subject = "test";
mailMessage.Body = "test";
mailMessage.IsBodyHtml = false;
mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.Priority = MailPriority.High;
smtp.Send(mailMessage);
Console.WriteLine("hooooooooooraaaaaaaaaaaaaaa");
Console.ReadKey();
}
catch (Exception err)
{
Console.WriteLine(err.InnerException.Message);
Console.ReadKey();
return;
}