Search This Blog

Sunday, October 30, 2011

How to migrate mail from one Gmail account to another on Windows, including Chats

This is the Microsoft Windows version of this article (though it contains screen shots from Mac). The Mac OSX version can be found here.

Recently at work, we got a new Gmail domain and had to switch from one Gmail account to another.

You can migrate your mail easily using POP3, but POP3 won't get your chats or preserve your labels. The superior solution is IMAP, even if it's a little more cumbersome. And even if you have already migrated using POP3, IMAP will still allow you to retrieve your chats and work for you on a tag-by-tag basis.

IMAP requires bit of a work-around—you must first fully download all your files to your machine, and only then can you migrate them back again into your new Gmail account.

Here's everything you need to get set up.

First, the downloads.
  1. Download Mozilla Thunderbird and install on your machine.
  2. Download and unzip the toIMAP files (we'll set these up later)
Now log in to your usual (old) Gmail account.


1. Click the gear icon in the upper-right corner and select Mail settings:

2. Click the Forwarding and POP/IMAP tab, scroll down to IMAP Access, and make sure it is turned on:

3. Click Labels and make sure that Chats and any other labels you want migrated are checked. (Note: If you already used the POP3 solution, you might want to limit only to Chats.)

4. Open Thunderbird, click Create a new account and use the address you want to pull the mail from, then click Continue:

Note: The wizard should smartly detect the proper settings; if not, you can click Manual config and enter the IMAP and SMTP settings shown below:

5. Click Create Account and let Thunderbird start downloading; this may take hours, and it goes without saying that the more mail you have, the longer the process will be. If you have to shut down for a while, to easily restart where you left off, just open Thunderbird, right-click, and click Get Messages in the context menu:

6. Log in to your new account and repeat steps 1 and 2 above for it. Make sure that you re-create any custom labels you used in your old account:

Now... go find something else to do for a few hours and come back to step 7 after Thunderbird (eventually) finishes.

7. Yay! Your e-mail finally downloaded! Rejoicing, right-click your account name, and click Settings (last option in the screen shot for step 5). Navigate to Server Settings, and copy the Local directory path at the bottom.

8. Open a new folder, and paste this address in the location bar. Keep this window open, as you'll need it for the following steps:

9. Go to Start > All Programs > Accessories > Notepad and start the program. Use it to open the toIMAP.cfg file in the toIMAP folder you downloaded to your Desktop. Make sure your configuration file is set up like the one below, subbing in your username and password:
     'host' : '',
     'ssl': True
10. Save the file and close it. Your configuration file is now set; all that is left is to run the file.

Go to your Windows Start menu and type cmd.exe in the search box, pressing ENTER. The Windows command-line prompt will open.

You'll need to be at the same level as the file; for Microsoft Vista, the path would be (where "YOU" is your username): C:\Users\YOU\Desktop\toIMAP. To do this, you'll need to change directories (cd) into the folder on your desktop:
cd C:\Users\YOU\Desktop\toIMAP
To run the uploader script, you'll use the following convention while still sitting at the level in step 9:
toIMAP.exe -m path_i_just_copied/FOLDER_NAME -f FOLDER_NAME
For example, if I want to upload the folder "admin stuff" (shown in step 8), I would type (surrounding my file path with quotation marks to bypass the space between "admin" and "stuff"):
toIMAP.exe -m "C:\Users\YOU\AppData\Roaming\Thunderbird\Profiles\76sexgps.default\ImapMail\\admin stuff" -f "admin stuff"
Some Gmail flags like Starred may need to omit the -f "admin stuff" part.

To specify a different Gmail tag than the name of the Thunderbird folder, just pass -f the new name, making sure that the tag already exists in your new account per step 6.

For example, to move your chats, you will not be able to use the same "Chats" name for your tag as that is reserved by Google. You'll need to create a new tag in your new account—I used "Archived Chats"—then import using the additional -f flag:
toIMAP.exe -m "C:\Users\YOU\AppData\Roaming\Thunderbird\Profiles\76sexgps.default\ImapMail\\[Gmail].sbd\Chats" -f "Archived Chats"
If your upload gets interrupted at any point, see the toIMAP directions on how to resume where you left off.

11. Repeat step 10 for as many folders as you need to migrate. Once you have gone through every folder you want backed up, you're done. Bliss is yours.


  1. This was a belated birthday gift for me. Appropriately published on the 30th of October. Thank you so much!

  2. You're quite welcome. :)

  3. I am found something else but I have seen your blog this information really useful for everyone.
    Gmail Account Support