I'm downloading my folders with a MCOIMAPFetchFoldersOperation
which gives me a nice list of all my folders:
INBOX
[Gmail]
[Gmail]/All Mail
[Gmail]/Drafts
[Gmail]/Important
[Gmail]/Sent Mail
[Gmail]/Starred
[Gmail]/Trash
When I'm fetching the messages for my folders I get a good chunk of duplicates, since the same message can exist in INBOX
, [Gmail]/All Mail
and [Gmail]/Important
et al. at the same time. I check for dupes with the messages UID, but a UID is only unique in a particular folder so that's useless in this case.
What would the most compatible approach be?
As noted in Gmail IMAP extensions, you can fetch the X-GM-MSGID
attribute for a message. This value is unique across folders.
You could fetch the X-GM-MSGID
value for all new messages, check which messages you have downloaded already, and download the ones that are missing.
This is what fetching a message id looks like in IMAP; not sure exactly how to do that in Mailcore2.
a006 FETCH 1 (X-GM-MSGID)
* 1 FETCH (X-GM-MSGID 1278455344230334865)
a006 OK FETCH (Success)
This is specific to Gmail. You can check whether the server supports it by looking for X-GM-EXT-1
in the CAPABILITY
response. As far as I know, there is no standard way to do this; the IMAP RFCs don't have the concept of the same message being present in multiple mailboxes.