Friday, January 2, 2009

Bending Outlook towards GMail

I use e-mail extensively, and usually for the most part working for clients whose infrastructures are based on MS Exchange. I have tried really hard to wean myself from Outlook, but unfortunately the alternatives bring about a host of other problems (tried Thunderbird and Evolution).

The two things I really like about GMail are:
* Nothing is deleted
* All is searchable

One really annoying problem is that the server administrator usually sets up cleaning of the "Deleted Items" folder and you loose all those "deleted" messages for future searches. I've been using GMail for personal use since 2004, and really like the idea that nothing needs to be deleted. Configuring Outlook 2003 to save all messages has proven to be a challenge. Here is how I did this.

First, I created a new folder under "Inbox" called "MyDeletedItems". I then wrote a VBA macro to move all messages from "Deleted Items" as well as all selected messages from any current view to "MyDeletedItems" folder.
Here is a code for the marco:

Sub MoveToMyDeletedFolder()

Dim x As Integer
Set myDeletedItemsFolder = Application.GetNamespace("MAPI").GetDefaultFolder(6).Folders("MyDeletedItems")

'This will move all selected messages from current view to "MyDeletedItems" folder.
Set sectedItems = Outlook.Application.ActiveExplorer.Selection
For x = 1 To sectedItems.Count
'MsgBox sectedItems.Item(x).SenderName & ":" & sectedItems.Item(x).Subject
sectedItems.Item(x).Move myDeletedItemsFolder
Next x

' this will move all items from standard DeletedItems folder to MyDeletedFolder
Set deletedItemsFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderDeletedItems)
Set delItems = deletedItemsFolder.Items
For x = 1 To delItems.Count
'MsgBox delItems.Item(x).SenderName & ":" & delItems.Item(x).Subject
delItems.Item(x).Move myDeletedItemsFolder
Next x

End Sub

The next step was to create a button and wire it to the macro, which was fairly easy. The really awkward way of adding a shortcut to buttons in Outlook shocked me. This is done by changing a text associated with a button. You need to pre-pend the name with a '&' character, which will make pressing Alt+'next character' possible. For instance, if the label on the button is "&Delete Message", then this button is associated with a Alt+D keyboard shortcut. Editing the button text is equally unfriendly. Thanks to all the people whose links I cannot reproduce here (i googled extensively to get all this information), I learned that in order to edit a button text, you have to do: Tools-> Customize, then, when the Customize dialog is up, right - click on the button to edit it's text.

As you can see from screenshot, my configuration is 'Alt+X'.

Since there is much written about Outlook security on the web, I will not repeat it here, but getting to run the macros is not straight forward. Instead of changing the security levels, I chose to create s self - signed certificate and us it for the macros.
Here are the steps to dot this:
  • Generate a self-signed certificate. This can be done with a variety of tools, but the simplest way to do this is to use MS - provided SelfCert.exe. On my machine, it is located here: c:/Program Files/Microsoft Office/Office11
  • In VBA Editor, do: Tools-> Digital Signature -> Choose .. and choose a certificate you just generated.
After this step, I was able to run the macro by just selecting a message in my inbox and pressing 'Alt+X'.
I think that when I started poking around all these steps, Outlook prompted me if I want to enable macros for X number of days, I selected some value and completely forgot it. Sure enough, after a dye days :) this stopped working and Outlook presented me with a message saying that I need to "Enable macros" from the application (Outlook). This was very annoying, and I had to dig further.
After some poking around, I figured that the certificate I created is a type of a "personal certificate", which can be seen in Internet Explorer Tools-> internet Options-> Content -> Certificates -> Personal. I exported this certificate and imported it back in as "Trusted Root Certificate", which solved this problem. I can run my macros again (till further obstacle from MS :)).

Once you import the certificate as "trusted Root Certificate", start Outlook again and try to run the macro, you will be presented with this dialog:

At this point, mark "Always trust macros from this publisher" and press "Enable Macros" button.

The last thing to make Outlook to behave close to GMail is to have a good search. While I generally believe that the Google Desktop is a search engine superior search to Windows search, I have a few gripes about it. First, when an e-mail message is found, there is no way to see what folder a message belongs to. Additionally, there is a pretty annoying bug in Google Desktop and Outlook integration, which sometimes prevents a link "Open in Outlook" to work. This makes it impossible to reply to and forward messages found through a search engine. Windows search, on the other hand has a tight integration with Outlook (surprise !), and is working well albeit slower than Google.

I have an e-mail environment for corporate e-mail that is somewhat close to GMail - nothing is deleted, and all is searchable.

I hope this help someone.