AE.Net.Mail连接超时



我正在创建一个程序,必须读取电子邮件并将其写入文本文件。我选择使用AE.Net.Mail内核包来完成此操作。但是,当我试图阅读电子邮件时,连接超时。下面是读取电子邮件的代码:

IC = new ImapClient("imap.gmail.com", yourEmail, yourPassword, AuthMethods.Login, 993, true);
IC.SelectMailbox("INBOX");
var Email = IC.GetMessage(-1);
string body = Email.Body;

调用IC.GetMessage(-1)时超时。这是什么原因呢?

检查它是否有效

public string ParseNewEmail()
{
// Connect to the IMAP server. The 'true' parameter specifies to use SSL, which is important (for Gmail at least)
ImapClient imapClient = new ImapClient(ConfigurationManager.AppSettings["ImapServer"], ConfigurationManager.AppSettings["UserId"], ConfigurationManager.AppSettings["Password"], AuthMethods.Login, 993, true);
var userName = ConfigurationManager.AppSettings["UserID"];
//  ImapClient imapClient = new ImapClient(ConfigurationManager.AppSettings["ImapServer"], "jayasreetestemail@gmail.com", "7Ywy7N[S", AuthMethods.Login, 993, true);
// Select a mailbox. Case-insensitive
imapClient.SelectMailbox("INBOX");
string emailJson="";          
imapClient.NewMessage += (sender, e) =>
{
var msg = imapClient.GetMessage(e.MessageCount - 1);
UpdatePackage up = new UpdatePackage();
up.Updates = ParseBody(msg.Body);
up.Subject = msg.Subject;
up.Body = msg.Body;
up.ProjectName = ApplicationName;              

emailJson = JsonConvert.SerializeObject(up);                          
string result = "";
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/json";
// result = client.UploadString("https://localhost:44300/ProjectUpdate/Update", "Post", emailJson);
result = client.UploadString("https://costcodevops.azurewebsites.net/ProjectUpdate/Update", "Post", emailJson);
Console.WriteLine(result);
}


};           

return emailJson;           
}

相关内容

  • 没有找到相关文章

最新更新