Friday, June 4, 2010

How to Make Gmail Play Nicely With Your Desktop Email Client [Annoyances]

 
 

Sent to you by David via Google Reader:

 
 

via Lifehacker by Whitson Gordon on 6/4/10

How to Make Gmail Play Nicely With Your Desktop Email ClientIf you use Gmail as your email backend but prefer a good old-fashioned desktop email client for handling your day-to-day email, you're probably aware that many clients—like Outlook or Mail.app—don't play that nice with Gmail. Here's how to fix that.

While Thunderbird no longer needs any extra work to become the ultimate Gmail IMAP client, mail clients, such as Mail.app or Outlook, do not exhibit normal behavior when using Gmail's servers.

Gmail may have won our hive five for best email client, but there are still quite a few of you that preferred something like Outlook or Apple Mail. The trouble is, even though Mozilla has caught on and made Thunderbird integrate almost perfectly with Gmail, most other mail clients still don't work all that well with Gmail. If you set up Gmail in Mail or Outlook, you wouldn't necessarily see all your labels, your sent messages may go into different folders, and archiving and deleting a message would archive it by default (with no real delete function in sight). Worst of all, Gmail thinks it knows what's best for you, but its recommended settings don't match up with most people's instincts (for example, most people expect that the delete function means "delete" and not "archive"). Here's how to make your client behave properly, without sacrificing all of Gmail's more advanced options.

Note: While there are a plethora of email clients out there, this guide will give specific directions for both Apple Mail and Outlook 2007, each of which is slightly different. In general, though, most mail clients should have similar options to one of the two (most likely Apple Mail), and these guidelines should at least help point you in the right direction.

Set Up Your Client with Gmail's IMAP Servers

How to Make Gmail Play Nicely With Your Desktop Email ClientIf you've tried to set up Gmail in a mail client before, this part isn't very different (in fact, if you already have Gmail set up in your IMAP client, you can skip this step). The very first thing you need to do is go to the Gmail web interface and go to Settings > Forwarding and POP/IMAP. Make sure you've enabled IMAP access to your account at the bottom of the page (see the screenshot at left). Save your changes and open up your mail client of choice.

You can find specific instructions for setting up your most email clients with Gmail's servers on Gmail's support page, complete with screenshots for each specific client, but the key things that you'll want to pay attention to are your incoming and outgoing servers (imap.gmail.com and smtp.gmail.com, respectively, even for Google Apps accounts), and that your port numbers for each are 993 (using SSL encryption) and 587 (using TLS, if available, otherwise using SSL). Both servers will need authentication with your Gmail username (which is your entire email address including the @domain.com portion) and password. Again, check your client-specific instructions on Gmail's support page to make sure you've followed everything "correctly". If you have, you should be able to view at least your inbox in your mail client, if not all the other folders.

Once you've completed the basic setup, it's time to get your desktop email client working with Gmail the way it should.

Enable Advanced IMAP Settings

One of the main problems with Gmail in most clients is that the client doesn't use Gmail's sent mail and trash folders by default, leading it to create its own labels that don't match up. In order to organize our folders and labels as best as possible, we're going to turn on a Gmail Labs feature that will allow us to customize which ones are shown in the mail client. In Gmail's web interface, go to Settings > Labs. Scroll down to "Advanced IMAP Controls", enable it, and save your settings.

How to Make Gmail Play Nicely With Your Desktop Email Client

If you're not seeing all of your Gmail labels in your client's sidebar (including Sent Mail, All Mail, Trash, and the like) you'll need to go to Settings > Labels in Gmail and enable them with your newly-installed lab feature. Check the new "Show in IMAP" box next to every label if they aren't checked already. This will make sure that we're able to use these folders in the mail client for what they were intended, and stop the mail client from creating its own sent or trash labels.

Note that labels in Gmail are the same as folders in pretty much every mail client, so from here on out I'll be referring to the two interchangeably.

How to Make Gmail Play Nicely With Your Desktop Email Client

Set Your Sent Mail and Trash Folders in Your Client

Head back into your client and you should see all your Gmail folders in the sidebar. We're going to set them to the default sent and trash folders for the client. If you're using Apple Mail, click on a folder (such as the "Sent Mail" folder under [Gmail]) and go to the Mailbox menu in the menu bar. Hover over "Use This Mailbox For" and click Sent. This will make Apple Mail use Gmail's Sent Mail folder for sent messages instead of creating its own.

How to Make Gmail Play Nicely With Your Desktop Email Client

You'll notice that after you enable this, a label called "Sent Messages" will show up with your other custom labels. Gmail has half-fixed this behavior recently, but to be safe (especially if you've been using Gmail in a client for awhile) drag all the messages from the "Sent Messages" label to the "Sent Mail" label, to make sure they're all there (it shouldn't produce any duplicates, since the Gmail server recognizes them as the same message). You can then delete the "Sent Messages" label. Do the same thing for Gmail's Drafts and Trash folder. You can to the same for Spam, but I prefer not to have two junk filters going at once, so I turned this feature off.

In Outlook, this process is slightly more complicated. Any mail you send in Outlook will automatically go into Gmail's "Sent Mail" folder, but you'll also have a local duplicate in Outlook's "Sent Items" folder. Depending on how you organize your mail, you may prefer that, but I've found the best way to keep these duplicates from showing up is to actually set your sent mail folder in Outlook to Gmail's Trash folder. This is scary sounding (and extremely counter-intuitive), but Gmail will still make sure your sent messages get saved in the Sent Mail folder. The duplicate that would be saved in Sent Items is just sent to the trash, where Gmail will permanently delete it after 30 days.

How to Make Gmail Play Nicely With Your Desktop Email ClientTo do this, go to Tools > Account Settings in Outlook, click on your Gmail account and then hit the "change" button. On the bottom left corner of the window, go to "More Settings" and click the Folders tab. Click on your Trash folder and hit OK. Then hit Next and Finish in your account settings to save that change.

Unfortunately, Outlook offers no way to remap the other folders, specifically Trash, meaning anything you delete will just be archived as before. You could just drag messages to the trash folder, but that isn't exactly ideal. Luckily, we can create macros to do what Outlook will not do for us. Go to Tools > Macros > Visual Basic Editor in Outlook and double click on ThisOutlookSession in the right pane. Being careful not to delete anything that may already be there, copy the following code into the box, courtesy of the Tap Consulting blog:

 Sub TrashMessages()      Set myOlApp = CreateObject("Outlook.Application")     Dim myNameSpace As NameSpace     Set myNameSpace = myOlApp.GetNamespace("MAPI")     Dim myExplorer As Explorer     Set myExplorer = myOlApp.ActiveExplorer      'Get the folder type, expected type is 0 i.e. mail folder. If other type of folder     'being used then abort macro as it should only be used with mail folders.     folderType = myExplorer.CurrentFolder.DefaultItemType      'Check that folder is mail folder     If TypeName(myExplorer) = "Nothing" Or folderType <> 0 Then     GoTo invalidMailbox     End If      'Locate root folder for this account     Set thisFolder = myExplorer.CurrentFolder     Do Until thisFolder.Parent = myNameSpace     Set thisFolder = thisFolder.Parent     Loop     Set accountFolder = thisFolder      'Identify selected messages     Dim selectedItems As Selection     Set selectedItems = myExplorer.Selection     Dim currentMailItem As MailItem     Dim iterator As Long      'Move messages to Deleted Items folder     Set trashFolder = accountFolder.Folders("[GMAIL]")     Set trashFolder = trashFolder.Folders("Trash")      Count = selectedItems.Count     For iterator = Count To 1 Step -1         On Error Resume Next         Set currentMailItem = selectedItems.Item(iterator)         currentMailItem.Move (trashFolder)     Next          Exit Sub  invalidMailbox:     MsgBox ("Macro configured only to work with mail folders! ")     Exit Sub  End Sub   

Save the macro and exit Visual Basic Editor. Back in the main Outlook window, go to View > Toolbars > Customize. Hit the Category tab and scroll down to Macros in the sidebar. Drag Project1.ThisOutlookSession.TrashMessages up to your toolbar, wherever you'd like the button for this action to be (I put it next to the delete "X" button).

How to Make Gmail Play Nicely With Your Desktop Email Client

You can give it a better icon by clicking on the button in the toolbar, hitting "Modify Selection" in the Customize window, and going to Change Button Image. I used the trash can icon. You can also check "Default Style" in the Modify Selection menu instead of "Image and Text" so the name doesn't take up space. Also, if you rename it to something like &1Trash, you can even get a hotkey to sent mail to the trash for you (the hotkey being Alt + whatever character comes after the ampersand, so in this case, Alt+1). Now, hitting Alt+1 or clicking the Trash button will delete the selected item. Note that you may need to restart your computer before the macro starts working.

How to Make Gmail Play Nicely With Your Desktop Email Client

Fix All Mail Issues and How to Archive Mail

The last major problem with most email clients is that they will see all mail in more than one label as a duplicate, meaning every time you receive a new message, your mail client will say you have two: one in Inbox, and one in All Mail. Additionally, there aren't any "archive" functions built in to a lot of mail clients, so we'll need to find another way to use this feature.

In Outlook, most of your work is cut out for you from the last step of the process. Since we've created our own "send to trash" button, the delete button still does what it always did: archives messages. So, when you want to delete a message, you can hit your new macro, and when you want to archive a message, you can hit the delete button. It isn't perfect, but as long as you remember the difference you should be fine (just remember that the delete key on your keyboard will archive the item).

To fix the All Mail duplicates problem, just go to Tools > IMAP Folders and hit the Query button to bring up a list of your folders. Unsubscribe from All Mail and uncheck the "When displaying hierarchy in Outlook, show only subscribed folders" box. This will keep All Mail visible in Outlook, but will not alert you to the new messages in that folder. If you want to hide folders from Outlook, you can still do so under the Label's section of Gmail's settings instead of unsubscribing from them in Outlook.

How to Make Gmail Play Nicely With Your Desktop Email Client

Since we can't unsubscribe from folders in Apple Mail, we'll have to do things a bit differently. In Gmail, create a new label and call it "MailArchive". Then, go to Settings > Labels and uncheck "Show in IMAP" next to All Mail. This will stop us from receiving duplicates notifications for new mail. If you'd like an All Mail folder to show up in your client, you can create a new smart folder in Mail by going to Mailbox > New Smart Mailbox and making one that includes every folder in the account. Make sure it is set to match "any" of the following conditions instead of "all" conditions. For some reason, this smart mailbox will show unread badges in the sidebar, but not on the dock icon. It also won't need to reload when you mark a message as read, so the badge will go away instantly when you read the message in your inbox.

How to Make Gmail Play Nicely With Your Desktop Email Client

Earlier, we set up Mail so that deleting messages actually deletes them (unlike our Outlook method), so we'll want to create our own shortcut for archiving messages instead. The easiest way to do this is to create a Service (note that this only works in Snow Leopard). Open up Automator, choose Service as your template, and set the top drop-downs to "no input" and "Mail". Then, find the Run Applescript action in the sidebar and drag it into the main window, copying and pasting this script from MacOSXHints into the text box:

 on run {input, parameters}   set target_account to "myaccount"   set target_mailbox to "MailArchive"   tell application "Mail"     set theSelectedMessages to selection     repeat with theMessage in theSelectedMessages       tell application "Mail"         move the theMessage to mailbox target_mailbox of account target_account       end tell     end repeat   end tell   return input end run   

You'll need to replace "myaccount" with the name of your account. Save the service as Archive Message.

How to Make Gmail Play Nicely With Your Desktop Email Client

Head into your System Preferences, click on Keyboard and then go to the Keyboard Shortcuts tab. Select Application Shortcuts in the sidebar, and hit the plus sign to add a new shortcut. You'll want the application set to Mail, the Menu Title set to Archive Message, and the keyboard shortcut set to whatever you want (mine is set to Cmd+1). Keep in mind you can't use keyboard shortcuts that are already taken.

How to Make Gmail Play Nicely With Your Desktop Email Client

Now, when you want to archive a message in mail, just hit your keyboard shortcut and it will move it to the MailArchive folder. This will archive the message in Gmail and add the "MailArchive" label to it, which shouldn't have any adverse effects since it will also show up in any other folders you want it in. If you have any unlabeled messages in your Gmail "All Mail" folder, you'll want to apply the "MailArchive" label to them so they show up in your new Smart Mailbox for All Mail. It's not pretty, but if you don't spend a ton of time in the Gmail web interface, you won't notice or care.


This certainly isn't the only way to do things, and depending on your personal preferences you may want to tweak a few of the above settings, or handle them differently altogether. This is the way I've found works best for me, though, for using Gmail in my native mail clients without losing all of Gmail's advanced features like archiving. If you have a different way of handling some of the above issues, lets hear about them in the comments.


 
 

Things you can do from here:

 
 

No comments: