POP3 无法在 GMail 上获取最新的电子邮件

POP3 not fetch newest emails on GMail

我使用 mailkit pop3 来获取电子邮件,但我发现它没有获取最新的电子邮件,每次我 运行 它 return 不同的邮件计数

using (Pop3Client client = new Pop3Client())
        {
            // Connect to the server
            client.Connect(hostname, port, useSsl);
            client.AuthenticationMechanisms.Remove("XOAUTH2");
            client.Authenticate((username), password);
            int messageCount = client.Count;
           // var folder = client.;

            // We want to download all messages
            List<MimeMessage> allMessages = new List<MimeMessage>(messageCount);

            for (int i = messageCount - 1; i > 0; i--)
            {
                var msg = client.GetMessage(i);
                allMessages.Add(msg);
            }
        }

我认为所有消息变量应该填充从最新电子邮件到旧电子邮件的所有电子邮件,但我发现所有消息 return 旧电子邮件,根本不包含所有新电子邮件,我搜索了很多并没有找到原因,你知道为什么会这样吗?我该如何解决? 我希望在这里找到任何帮助,在此先感谢

你连接到 GMail 了吗?

这是一种 GMail 行为,根据您的 POP 设置(在 GMail 网络应用设置页面中设置),将决定客户端看到的消息。

这不是 MailKit 问题。

来自 Google 自己的 FAQ 在标题为 "Emails aren't downloading correctly" 的部分中指出:

After you set up POP in your Gmail settings, your emails become available in batches. It might take a while to see all your emails.

Note: Gmail downloads a copy of every email you send or receive, except for emails in Chats, Spam, and Trash. To avoid duplicates, Gmail doesn't download emails sent within your mail client, but you can still see them if you log in to Gmail.

If you continue to have problems downloading emails, try using recent mode:

  1. In your email client's POP settings page, find the "Email address" or "User name" field.
  2. Add recent: in front of your email address. For example, recent:example@gmail.com.

If that doesn't fix the problem, try deleting your Gmail address from your email client, then re-adding it.