ae.net.mail检索来自不同邮箱的邮件

时间:2018-05-08 19:35:48

标签: c# email

那么,我如何从不是INBOX的邮箱中准确检索邮件?我尝试了其他任何邮箱 -

public static MailMessage[] LastNMails(ImapClient listenClient, int count)
{
    int endMailBox = listenClient.GetMessageCount() - 1;
    return listenClient.GetMessages(endMailBox - count, endMailBox, false, false);
}


ImapClient listenClient=new ImapClient(my data here.. doesnt matter);
var listMailboxes = listenClient.ListMailboxes(string.Empty, "*");
List<string> working = new List<string>();
foreach (var Mailbox in listMailboxes)
{
    try
    {
        listenClient.SelectMailbox(Mailbox.Name);
        working.Add(Mailbox.Name);
    }
    catch (Exception e)
    {
    }
}
MailMessage[] mm = null;
foreach (var item in working)
{
    try
    {
        listenClient.SelectMailbox(item);
        mm = LastNMails(listenClient, 1);
        Console.WriteLine(item+" YES");
    }
    catch (Exception e)
    {
        Console.WriteLine(item+ " FAILED");
    }

}

然而,除了INBOX或[Gmail] / All Mail之外的任何邮箱都打印FAILED,不知道为什么?

输出(如果重要)https://i.stack.imgur.com/XI6fF.png

错误 -

  

连接尝试失败,因为连接方没有   在一段时间后正确回应,或建立连接   失败,因为连接的主机无法响应。

0 个答案:

没有答案