I finally found an use for Microsoft's Windows Live Mail, a mail client that replaces Outlook Express as the light version of Outlook. Windows Live Mail has a unique characteristic: it's free and it allows you to access Hotmail accounts. Microsoft also provides a plug-in for Outlook with an exuberant description:
"With Microsoft Office Outlook Connector, you can use Microsoft Office Outlook 2003 or Microsoft Office Outlook 2007 to access and manage your Microsoft Windows Live Hotmail or Microsoft Office Live Mail accounts, including e-mail messages and contacts for free!"
Microsoft probably thinks it makes you a favor by providing ways to access your mail from a desktop client, so it uses a proprietary mechanism that can only be interpreted by Microsoft's software.
But I digress: Windows Live Mail is a good way to migrate the messages from your old Hotmail accounts to Gmail.
1. Enable IMAP for Gmail.
2. Download Windows Live Mail. Microsoft no longer links to the standalone version of the product and it forces you to install a package, but you can choose the software you want to install.
3. Add the Hotmail accounts from Windows Live Mail's interface.
4. Add your Gmail account and make sure you manually configure the IMAP settings.
5. To prevent some new Gmail labels from being created, right-click on your Gmail account from Windows Live Mail's sidebar, select Properties, go to the IMAP tab and uncheck "Store special folders on IMAP server".
6. Then go to the inbox of each Hotmail account, select all the messages (Ctrl+A), right-click, choose "Move to folder..." (or "Copy to folder..." if you want to keep them in Hotmail) and select the Inbox of your Gmail account (or create a new folder). You should repeat this for each folder created in Hotmail.
If you don't expect to receive other message in your Hotmail accounts, uninstall Windows Live Mail. Otherwise, check your Hotmail accounts from time to time and manually move the messages to Gmail. Microsoft doesn't allow you to create rules for IMAP and HTTP mail accounts, so you can't forward new messages to Gmail. If you try to use the forwarding option from Hotmail, you'll notice that Microsoft still tries to keep your mail hostage.