Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

   .....
}
like image 217
Dryadwoods Avatar asked Feb 23 '23 03:02

Dryadwoods


1 Answers

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.

like image 119
foens Avatar answered Feb 24 '23 15:02

foens