gpt4 book ai didi

c# - 连接尝试失败 HRESULT 异常 : 0x8007274C

转载 作者:行者123 更新时间:2023-11-30 17:48:00 24 4
gpt4 key购买 nike

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

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

最佳答案

我之前遇到过这种情况,当时我的防病毒软件认为未知/未签名的进程正在尝试发送电子邮件。尝试关闭您的 A/V 或防火墙一分钟,然后重试。

关于c# - 连接尝试失败 HRESULT 异常 : 0x8007274C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23862696/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com