Skip to Main Content

go to Indiana University Indiana University


Creating a Gmail-Like Experience in Outlook: Using Macros to Help Organize Incoming Mail in Outlook

This is the first of a couple of articles about how to create specific functionality from Gmail in Outlook using various tools and features. Today’s article begins by re-creating one of the keyboard shortcuts that is used frequently in Gmail.

Before I get started, a little bit of fair warning. This article is not for beginning users of Microsoft Outlook or for users who only use one incoming mail folder. It requires a decent understanding about how to organize email, work with the Office 2010 interface, and knowledge about how to create and modify a macro. Information about how to create a macro can be found in the workshop Excel 2010: Basic Automation Using Macros and more in-depth Visual Basic for Applications information can be found in the workshop Excel 2010: Advanced Macros and User Defined Functions.

At this year’s Statewide IT Conference, I attended a session by Martin Wagner called INBOX ZERO – Master your email inbox using GTD principles. I’ve since streamlined my mail management, turned off Outlook’s email reminders, and generally become more efficient at managing my email.

But there was a catch…

Being a long-time Gmail user, I wanted to get more Gmail-like functionality added into Outlook.

If you aren’t aware, Gmail has a bunch of keyboard shortcuts built in that allow you to do some very useful things like select messages, archive messages, begin composing a message, search, etc. Being an avid Gmail user, I wanted to put this functionality into Outlook to make working with email easier.

Some of these are already built-in to Outlook — Ctrl-N for a new message, for example — but the most useful of them (in my mind) is missing from Outlook — archiving.

So, I set myself on a mission to find a way to make Outlook give me a keyboard shortcut to move messages. After some digging around Outlook help and the internet in general, I found one. By using VBA I wrote a series of macros that help me keep my inbox empty and myself on task.

Here’s the sample macro:

Sub ArchiveMessages()
'A macro that moves selected mail items to the desired folder.

'Define Variables
Dim OutlookApplication As New Outlook.Application
Dim OutlookExplorer As Outlook.Explorer
Dim SelectedItems As Outlook.Selection
Dim NameSpace As Outlook.NameSpace
Dim DestinationFolder As Outlook.Folder
Dim i As Integer

'Set Variables
Set OutlookExplorer = OutlookApplication.ActiveExplorer
Set SelectedItems = OutlookExplorer.Selection
Set NameSpace = OutlookApplication.GetNamespace("MAPI")
Set DestinationFolder = NameSpace.GetDefaultFolder(olFolderInbox).Folders("Archive Folder Name Goes Here")
For i = 1 To SelectedItems.Count
SelectedItems.Item(i).UnRead = False
SelectedItems.Item(i).Move DestinationFolder
Next i
End Sub

Let’s talk a little bit about what this done, then I’ll tell you how to get your coveted keyboard shortcut.

First, all of our variables are explicitly defined. I’m a firm believer in the Option Explicit switch and use it constantly.

Second, let’s look at the Set Variables section. In order to work with the messages we have selected in a macro, we need to turn them into an object within the macro itself. To do this, it’s best practice to start from the Application and drill down to the selection using various properties of various other objects. This section is doing just that:

  • OutlookApplication is a variable that instantiates the current instance of the Outlook application so we can access the ActiveExplorer property.
  • OutlookExplorer refers to the current window of the Outlook application and allows us to access the Selection property directly.
  • SelectedItems will refer to whatever items is selected (multiple items are allowed).
  • DestinationFolder points to the destination folder for the selected items, assuming it’s a child of Inbox.

Once we have the selection and destination folder designated, it’s easy to write a For Next loop that moves through all the selected items, marks them as read, and moves them to the appropriate folder:

For i = 1 To SelectedItems.Count
SelectedItems.Item(i).UnRead = False
SelectedItems.Item(i).Move DestinationFolder
Next i

Pretty straight-forward macro for archiving messages. Now, how do we give this message a keyboard shortcut? The answer to that question is a little bit round-about. We put it on the Quick Access Toolbar. Every item in the Quick Access Toolbar has a keyboard shortcut of alt+ a number starting with 1 and moving up from left to right.

My typical mail processing method involves three folders: 01 – Today, 02 – Week’s End, and 03 – Archive. To facilitate my message processing, I’ve created macros similar to these and assigned them to the alt+1, alt+2, and alt+3 spots on the Quick Access Toolbar respectively.

These macros are truly time and frustration savers for me. My next project is to tackle getting these set up on my IUAnyWare instance of Outlook to make message processing on my iPad much easier.

Keep your eyes peeled for a follow up post detailing some other, exciting functionality to be added to Outlook using macros and other enhancements as I slowly move myself toward a more Gmail-like email experience on the desktop!


One Response to "Creating a Gmail-Like Experience in Outlook: Using Macros to Help Organize Incoming Mail in Outlook" to “Creating a Gmail-Like Experience in Outlook: Using Macros to Help Organize Incoming Mail in Outlook”

  1. Ari Wahyudi Says:

    Nice idea. I never thought that macro can be used with microsoft outlook! Credits to you.

Leave a Reply

 

Get Training Tips via RSS Subscribe to Entries feed or Read Comments via RSS Subscribe to Comments feed.