Search code examples
vb.netpop3

How to retrieve LASTEST emails from a POP3 Server?


I was recently working on a project that involving connection to a POP3 Server. I was using this piece of C# from CodeProject(http://www.codeproject.com/Articles/6062/A-POP3-Client-in-C-NET), had complied it into a DLL and was using it in VB.NET.

I'd connected to my Hotmail Account (not many mails) and it seems to work just fine. After that, I connected to my GMail account... I started seeing errors!

POP3 is meant to fetch emails only from the Inbox. Even when I made my own program to cross-check the problem, I saw that when I requested for the number of messages, the GMail POP3 Server returned a value which is about 5 times less than the actual inbox size.

255 Emails in my Inbox?? Online it shows me 2,414 emails in my Inbox. And secondly, my MAIN QUESTION is that how does one fetch the LATEST email from the POP3 Mailbox. What I've fetched here was an e-mail with ID 1! I want to fetch the top 20 emails (that were most recently delivered to the account)...

Is there any work around for how to fetch the LATEST email from the POP3 Server rather than the oldest emails? I've also tried to connect to the Hotmail POP3 Mail Server. Again a "RETR 1" command fetches me the oldest email and not the latest one! Any known work-around?


Solution

  • I think your question is answered here: "Incorrect message count using STAT command" http://groups.google.com/group/Gmail-Help-POP-and-IMAP-en/browse_thread/thread/8be2c0b2bf383c15/7c57310cd5b11fc9?pli=1

    [Update on 2016-06-30: The above link will not necessarily work, demonstrating why link-only answers are frowned upon so...]

    The messages are made available in batches. After retrieving a batch, re-connect to get the next batch. Repeat as required.