连接尝试失败来自HRESULT的异常:0x8007274C

时间:2014-05-26 04:26:45

标签: c#

我试图通过网络向雅虎邮件帐户发送邮件,并且前一天运行良好。今天,当我运行相同的代码而没有任何更改(但使用不同的网络连接)时,会显示以下错误。

A connection attempt failed because the connected party did not properly respond 
after a period of time, or established connection failed because connected host 
has failed to respond. (Exception from HRESULT: 0x8007274C)  

我了解到错误是由于连接超时造成的。我检查了Allow network loopback属性,但显示错误 有什么办法可以解决吗?

为什么它只运行一次而现在却没有?

使用System.Threading.Tasks; 使用EASendMailRT;

private async void buttonSend_Click(object sender, RoutedEventArgs e)  
          {
              buttonSend.IsEnabled = false;  
              await Send_Email();  
              buttonSend.IsEnabled = true;  
          }  
          private async Task Send_Email()  
          {
              string Result = "";  
              try  
              {  
              SmtpMail oMail = new SmtpMail("TryIt");  
              SmtpClient oSmtp = new SmtpClient();  

            // Set sender email address, please change it to yours
              oMail.From = new MailAddress("apple@yahoo.com");  

            // Add recipient email address, please change it to yours
            oMail.To.Add(new MailAddress("banana@yahoo.com"));

            // Set email subject and email body text
              oMail.Subject = "Subject entered";
              oMail.TextBody = "body of mail";  

              // Your SMTP server address  
              SmtpServer oServer = new SmtpServer("smtp.mail.yahoo.com");  

              // User and password for SMTP authentication              
              oServer.User = "apple@yahoo.com";    
              oServer.Password = "testpassword";  
              //yahoomail requires TLS/SSL and SMTP port is 465
              // If your SMTP server requires TLS connection on 25 port, please add this line    
              //oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;  

              // If your SMTP server requires SSL connection on 465 port, please add this line  
              oServer.Port = 465;  
              oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;  

              await oSmtp.SendMailAsync(oServer, oMail);  
              Result = "Email was sent";  
          }  
          catch (Exception ep)  
          {
              Result = String.Format("Failed to send email with the following error: {0}", ep.Message);  
          }  

          // Display Result by Diaglog box  
          Windows.UI.Popups.MessageDialog dlg = new  
              Windows.UI.Popups.MessageDialog(Result);  

          await dlg.ShowAsync();  
      }  

1 个答案:

答案 0 :(得分:1)

在我的AntiVirus认为未知/未签名进程尝试发送电子邮件之前,我遇到过这种情况。尝试关闭A / V或防火墙一分钟并再次尝试。