user3124361
user3124361

Reputation: 489

A connection attempt failed Exception from HRESULT: 0x8007274C

I tried to send mail to a Yahoo mail account over a network and it had worked well the day before. Today when I run the same code without any changes (but using a different network connection), the following error is displayed.

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)  

I learned that the error is due to connection time out. I have checked the Allow network loopback properties ,yet the error gets displayed.
Is there any way to solve it?

Why is it that it ran once and now it doesn`t?

using System.Threading.Tasks; using 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("[email protected]");  

            // Add recipient email address, please change it to yours
            oMail.To.Add(new MailAddress("[email protected]"));

            // 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 = "[email protected]";    
              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();  
      }  

Upvotes: 3

Views: 1676

Answers (1)

Paul
Paul

Reputation: 36319

I've run into that before when my AntiVirus thought that an unknown / unsigned process was attempting to send emails. Try turning off your A/V or firewall for a minute and trying it again.

Upvotes: 1

Related Questions