How to import mail from gmail without duplicates or losing messages?

Hello,

I am trying to import emails from gmail but I cannot find a reliable way to do it. Here is how I used to do it to import every message with a given label:

  • rebuild the mailbox (corresponding to the label) in Mail to make sure the local cache is clean (I don’t know if it’s necessary, but better safe than sorry);
  • while still in Mail, select and import every message;
  • go to the label in gmail, select and delete every conversation (to make sure I don’t get duplicates, I assume that messages will only be imported once for one of their labels).

The problem with this approach is that Mail only shows messages that have been individually labeled, whereas gmail shows the whole conversation. So importing will only get labeled messages, and messages in the conversation that are not labeled will only be deleted, thus lost.

(I have no idea how gmail labels work in that regard: I assume that if a conversation has a label, any subsequent message will get it to. But if I put a label on a reply I get, the initial message I sent does not seem to have the label.)

I don’t know how to do things differently. I guess I could (but I don’t know how to do any of these):

  • import directly from gmail;
  • display only messages (and not conversations) in gmail with a given label;
  • don’t delete the messages and have them imported several times, then find and remove duplicate email messages in EF;
  • have Mail display conversations to import them;
  • have gmail give me a number of messages, then manually track the ones that are missing (comparing the numbers in Mail and in gmail).

I just checked mails I imported last week (luckily they were still in gmail’s trash), and I found that some were indeed missing from the import (typically mails at the beginning of a conversation).

I guess I’m not the only one having this issue with getting mails out of gmail. If anyone has a suggestion as to how I could proceed, it would be great.

Thanks,

Alan

I’ve spent a while researching this, and I think I may have found a solution.

First, the reason why messages may be in a conversation yet not be labeled is not clear. I expect that it is because the label was applied before a new message was imported (typically in Mail) with a matching subject, extending the conversation, but not having the label set.

To make sure every message in conversations have labels, here is what I do:

  • I go to the label that I want to import;
  • I select every conversations;
  • I label them with a new label “to_import”;
  • I then re-launch Mail so that it sees the new folder;
  • I import the mail from there.

(As a data point, under the initial label I have 846 messages, whereas there are 905 in “to_import”, meaning I would have lost about 60 messages.)

Also, to make sure things don’t go badly, I delete the messages from Mail itself. To do this, you need to configure Mail correctly:
select the [Gmail]/Trash folder in Mail, and click on “Mailbox -> Use This Mailbox For -> Trash”.

This way only the messages imported will be deleted, and as they will be deleted (i.e. moved to gmail’s trash), there won’t be duplicates.

If someone sees some flaws in this setup, please let me know.

Alan