SmtpClient失败发送消息Hotmail c#

时间:2017-05-26 18:53:30

标签: c# email smtp

我正在尝试通过SmtpClient发送电子邮件。我从数据库查询中提取收件人电子邮件。但是,在尝试发送时,我得到一个内部例外的错误:

  

"连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应65.55.176.126:578"

System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
string email = query.Email;
message.To.Add(new MailAddress(email));
message.Subject = "Your Application Status has been updated!";
message.From = new System.Net.Mail.MailAddress("test234@outlook.com");
message.Body = "Dear Applicant, we are sorry to announce to you that your application has been declined!";
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.live.com", 578);
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("test234@outlook.com", "somepassword");
try
{
    smtp.Send(message);
}
catch (Exception ex)
{

    throw new Exception( "Error: " + ex.Message);
}

0 个答案:

没有答案