IMAP Mailbox Migration utility for Gmail/iCloud and Calendar Migration tips
I recently ditched my iPhone in favor of a new Android phone. Not only is it faster, it does more. But...I was using iCloud for my email (thanks to the VERY tight integration with the iPhone). Naturally, it was IMAP, and I created lots of folders, sub-folders, and had a ton of stuff archived. Also naturally, Apple decided to not leave you any way to migrate FROM their system easily.
So, I wrote the attached program in Perl. It has one function: connect to two different IMAP systems (source and destination), and move EVERYTHING from the source to the destination. It creates the exact same folder structure, and copies all the messages over, automatically. I migrated from iCloud to Gmail in about 10 minutes. Should just have to modify the user ID/password/server names (obviously), and off it goes.
Also, when it comes to migrating your iCloud calendars to Google Calendar, there is an easy option. Make your iCloud calendar shareable, then copy the link it gives you. Run "wget http://<that link name>", to download the calendar to your local system. It's a huge hex string, but it's an .ICS file, so rename it to something useable. Then, go into Google Calendar, and import it. Done.
NOTE: The link will start with "caldav://", so change it to "http://" when you download it, otherwise it will fail.