Archived Forum Post

Index of archived forum posts

Question:

How do we separate those emails that we've already downloaded and those that we haven't?

Jul 23 '12 at 10:13

This client is using Exchange 2003. The POP3 Uidls that we get back look like this - "AAzzz+GABAQmSpNxMHGHeyUSOgl9I6u/". We use a comparison in our code, "If uidl > LastUid Then" to determine where we left off last time, so we know which email that we've already downloaded, and which ones we need to download. Because these Uidls are not in a numerical or alphabetical order, our comparison is not working.

This approach has worked fine with our other clients. So, I'm assuming this is an issue with Exchange 2003 and not with your new update. If I'm correct, then do you have a different, better approach that we should be taking here. How do we separate those emails that we've already downloaded and those that we haven't?


Answer

The GetUidls method returns the full set of UIDLs for all the emails in the INBOX of a POP3 server. The technique used by Chilkat for automated order processing is to do this:

  1. When finished processing emails, save the complete set of UIDLs returned by GetUidls to a file. This could be a simple text file with one UIDL per line.
  2. When checking for new emails, first load the UIDLs from the previous time into a hash table.
  3. Call GetUidls to fetch the new complete set of UIDLs from the POP3 server.
  4. Iterate over the new list of UIDLs. For each one, check to see if it exists in your hash table. If so, then it's an "already seen" email. If not, then process the email (by downloading the email by UIDL).
  5. Go to step #1.