OpenPop - Gmail - GetMessageCount() returns 0 (zero)

旧时模样 提交于 2019-12-12 12:25:54

问题


When connecting to Gmail with OpenPop, I can only retrieve an email once, even if I do not delete it. Using GetMessageCount() I always receive 0 emails. How can I get all the emails that are there?

Only after reading them and processing them do I give order to delete. I am using the following code to get the emails:

using (var client = new Pop3Client())
{
    // Connect to the server
    client.Connect(serverData.Hostname, serverData.Port, serverData.UseSsl);

    // Authenticate ourselves towards the server
    client.Authenticate(serverData.Username, serverData.Password, AuthenticationMethod.UsernameAndPassword);

    var emailAmount = client.GetMessageSizes().Count;

    // Fetch all the current uids seen
    var msgCount = client.GetMessageCount();

   .....
}

回答1:


Gmail is special. Take a look at this StackOverflow post which explains the non-standard behavior.

What you are interested in, is that Gmail will only show a message in ONE POP3 session, unless you do special stuff, like prepending recent: in front of your username.




回答2:


Getting only the unread mails is how POP3 is supposed to work. If you want to see and manage older mails, you should use IMAP instead.



来源:https://stackoverflow.com/questions/8519656/openpop-gmail-getmessagecount-returns-0-zero

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