I am trying to replicate a Google Apps mailbox into another Google account. I am using the IMAP library in Python.
I am able to get a unique UID for each mailbox. I could, download each message from each mailbox using thie UID.
The problem is that the unique UID is per mailbox, not per account. For example, one email may reside in two mailboxes, or have two labels. It will show up as two separate UIDs. If I download the email twice, they are no longer the same email. When one is deleted, the other will remain, etc.
Gmail has a X-GM-MSGID which gives a unique ID per the account.
At the moment, the only way I know of getting this X-GM-MSGID is by first getting the UID and requesting it's X-GM-MSGID. If the inbox has 10,000 emails, this will become a lot of requests. Is there a another way to get the X-GM-MSGID of all emails in an inbox, or even better, of all mailboxes?
I believe once I have the unique ID of each email, I can then FETCH the flags, time and content of each email and APPEND it onto the new server.