POP3 not fetch newest emails on GMail

柔情痞子 提交于 2019-12-13 01:19:21

问题


I use mailkit pop3 to fetch emails, but I find it didn't fetch newest emails and each time I run it return different messages count number

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

I supposed that all messages variable should be filled with all emails ordered from newest emails to old emails but I found all messages return old emails and not contains at all new emails at all, I searched a lot and didn't find the reason, Do you know why that happened and how can I fix that ? I wish to find any help here and Thanks in advance


回答1:


Are you connecting to GMail, by any chance?

This is a GMail behavior where, depending on your POP settings (as set in the GMail web app Settings page), will determine what messages the client sees.

This is not a MailKit issue.

From Google's own FAQ in the section titled "Emails aren't downloading correctly", it states:

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.



来源:https://stackoverflow.com/questions/53316125/pop3-not-fetch-newest-emails-on-gmail

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!