Skip navigation

Tracking Your Email Mileage

Downloads
9167.zip

MY COLUMNS about working with items arriving in your Inbox folder have sparked some interesting feedback. One reader who manages a staff that handles customer complaints wondered whether a way exists to customize the Inbox to count the number of messages received.

One method I devised is to maintain an Outlook item for each day and store the running count in that item. To hold these items, you must create a Message Count folder as a subfolder of the Inbox. The code in Listing 1 sets up the Inbox so that VBA can monitor the Inbox for new items. It also calls the UpdateCounter subroutine for each new item that arrives in the Inbox. Put the code from Listing 1 in the ThisOutlookSession module of the Outlook VBA window.

You'll find the UpdateCounter procedure in Listing 2, page 158. You can put this code either into ThisOutlookSession or into a separate code module. Let's look at how this code works. As the following lines show, the first message that arrives on a particular day triggers the creation of a new item in the Message Count folder:

Set objTodayCount = _
objMessageCountFolder.Items.Add
("IPM.Post")

Using the Add method on a MAPIFolder object's Items collection lets you create an item directly in that folder. The argument for the Add method is the message class of the type of item that you want to create; in this case, a post item that uses the default post form. If you prefer to use a published custom form, substitute its published class for "IPM.Post."

The subject for each day's item is the date in your PC's long format. For example, on my system that has the Windows regional settings set to English—United States regional settings, the item for October 16, 2000, will have the subject "Monday, October 16, 2000." The FormatDateTime() function is handy for this type of quick conversion of a date to a consistent format. (If you'd rather use a custom date format, use the Format() function to build the custom format.)

On every item, Outlook provides two properties, BillingInformation and Mileage, that you can use to add fields and to store information without creating a custom form. In this case, the Mileage property is appropriate. As the following code shows, when you create the new item for each day, the code sets Mileage to the initial value of 1. Thereafter, the code increments Mileage by 1:

objTodayCount.Mileage = _
objTodayCount.Mileage + 1

Although Mileage is technically a string property, you can perform addition on it because the code ensures that the Mileage property always contains a number.

The result of this process is an item for each day with a Mileage property holding the count of items received in the Inbox. To make the item count easy to see, click View, Current View, Define Views to create a new table view for the Message Count folder. You can name the new view Message Mileage, and the view should include only the Subject field, the Mileage field, and the Modified field, which shows you the last time the item was updated. Figure 1 shows how this view will look.

Be aware that the Microsoft article "OL2000: ItemAdd Event Doesn't Fire in Some Scenarios" (http://support.microsoft.com/support/kb/articles/q249/ 1/56.asp) suggests that this method of keeping a running count might not be accurate if you receive many new messages at one time. Also, if you want to analyze your message count data in more detail, select all the items in the Message Count folder, click Edit, Copy, then open a Microsoft Excel worksheet and click Paste. Excel will neatly arrange the data from the Outlook folder view in rows and columns.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish