Leaving Gmail is trickier. Third-party services, such as the command-line Got Your Back and Gmail Keeper tools, or online apps like Backupify and BackupGoo, can be used to automate the process without needing much babysitting.
With both Gmail and Yahoo, the easiest way to export your email is via IMAP connectivity, which is supported by each service. Install an email client that supports IMAP -- such as Outlook or Mozilla Thunderbird -- then download your email locally.
You can also import email to Yahoo using this method, but it's not easy. When you set up a local mail client for IMAP, you can copy mail to or from the remote IMAP folders. So if you have two services set up in the same mail client via IMAP, you can transfer mail between them simply by copying them between remote IMAP folders.
The process is slow and a bit tedious, especially if you have a lot of folders, but it can be done. And this, or using a third-party application such as TrueSwitch (see below) is the only way to import email to Yahoo.
Outlook.com does not support IMAP, but you can use Microsoft's Outlook Connector tool, together with Outlook (the desktop application, which does support IMAP), to accomplish the same thing. (The Outlook Connector is built into Outlook 2013 and Outlook for Mac 2011; it can be installed to earlier versions.)
While there is no built-in import mechanism for Outlook.com, there is at least one third-party outfit that might help. TrueSwitch copies email messages and contacts from one account to another for you, provides mail forwarding between accounts, and notifies contacts of the upcoming change in address. TrueSwitch is free for some services, such as Gmail and Outlook.com; it will also work with Yahoo, but you have to purchase a copy of the software for $29.95.
Migrating contact information, thankfully, isn't as hard. Gmail (and Google generally) makes it easy to do this. The Google Takeout service lets you create an archive which contains data associated with your various Google accounts. Contacts information can be downloaded as a CSV file, vCards or as an HTML file.
One very nice feature of Yahoo's contact export option is the variety of formats. Not only does it export in Outlook-friendly CSV files, but also a CSV format recognized by Yahoo itself (in case you want to re-import to a new account), a Mozilla Thunderbird-native format, and either multiple vCards in a ZIP file or a single vCard. Contacts can also be imported from a whole plethora of sources -- another Yahoo account (you'll need the login and password), a variety of social networks or as a CSV file exported from a desktop program.
Sign up for CIO Asia eNewsletters.