Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 连接尝试失败,HRESULT异常:0x8007274C_C# - Fatal编程技术网

C# 连接尝试失败,HRESULT异常:0x8007274C

C# 连接尝试失败,HRESULT异常:0x8007274C,c#,C#,我试图通过网络将邮件发送到Yahoo mail帐户,但在前一天它运行良好。今天,当我运行相同的代码而不做任何更改(但使用不同的网络连接)时,将显示以下错误 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 faile

我试图通过网络将邮件发送到Yahoo mail帐户,但在前一天它运行良好。今天,当我运行相同的代码而不做任何更改(但使用不同的网络连接)时,将显示以下错误

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)  
我了解到错误是由于连接超时造成的。我已检查了
允许网络环回
属性,但仍显示错误。
有办法解决吗

为什么它曾经运行过一次,现在却没有

使用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();  
      }  

当我的防病毒软件认为一个未知/未签名的进程试图发送电子邮件时,我曾经遇到过这种情况。尝试关闭A/V或防火墙一分钟,然后再试一次。

为什么它只运行了一次,而现在却没有?可能是因为你改变了什么。就像它使用的网络连接一样。您是否测试过使用该网络连接的其他应用程序可以与雅虎的邮件服务器通信?是的,其他应用程序可以与雅虎或任何其他邮件服务器通信。那么我们没有足够的信息来帮助您。发布代码的相关部分,详细说明如何以及在哪里失败。