Jump to content
Mark Williams

Retrieving gmail email with TIDPop3

Recommended Posts

I am trying to retrieve the contents of my gmail using TIDPop3 as a test.

 

I can connect, login fine.

 

I then use CheckMessages to find out how many emails there are. It tells me there are 274.

 

However, my Gmail Inbox believes there are over 1500 and my All Mail box tells me there are over 7500.

 

I download the headers using following:

Count:=CheckMessages;
for i := 1 to count do
  begin
    IDMessage1.Clear;
    RetrieveHeader(i, IDMessage1);
    ListBox1.Items.Add(IDMessage1.From.Address+' '+IDMessage1.Subject+' '+DateTimeToStr(IDmessage1.Date));
  end;

It is starting (almost) with the oldest emails and then proceeding forwards to the most recent.

 

However, the first email it retrieves is not the oldest. It skips a handful. Then it gets a small batch, skips some more and then produces a larger batch. 

 

It all seems a bit random.

 

Are there any obvious reasons why CheckMessages is reporting only a small portion of the actual emails and also why RetrieveHeader may be skipping batches?

 

Out if interest, I tried RetrieveHeader outside the range of CheckMessages, but well within the true email count and (unsurprisingly) it threw up a range error.

Share this post


Link to post
1 hour ago, Mark Williams said:

I am trying to retrieve the contents of my gmail using TIDPop3 as a test.

Why POP3 and not IMAP?  GMail's POP3 implementation is a bit of an oddball, it does not exhibit standard POP3 behaviors.  This is described in GMail's POP3 documentation.  This is why I question your choice to use POP3 to begin with.

1 hour ago, Mark Williams said:

I then use CheckMessages to find out how many emails there are. It tells me there are 274.

More precisely, it tells you that you have 274 emails that have not been downloaded via POP3 yet.

1 hour ago, Mark Williams said:

However, my Gmail Inbox believes there are over 1500 and my All Mail box tells me there are over 7500.

Once you have downloaded a Gmail email via POP3, you can't access it again via POP3, even if it still exists in the Inbox.  In your Gmail settings, you have to specify what you want Gmail to do with emails that have been downloaded via PO3.

  • Thanks 1

Share this post


Link to post
2 hours ago, Remy Lebeau said:

Why POP3 and not IMAP?

Sorry to have to say "ignorance"! Didn't know there was an INDY IMAP client.

 

Thanks for pointing in the right direction. Have abandoned Pop3.

Share this post


Link to post

I'm just going to swerve it and use the IMAP component, which seems much fitter for purpose. Just grateful I hadn't invested too much time in Pop3 before hitting a snag.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×