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.

Discuss this Article 14

dwh (not verified)
on Mar 29, 2003
Works great in XP - many thanks for a neat solution...
Stephen Whiteley (not verified)
on Sep 20, 2000
The code works fine for me. I think you will find after you close and restart Outlook you'll have better luck.
Sue Mosher (not verified)
on Apr 20, 2001
Sven, for a server-based solution, you'll want to look at adding an Exchange Server Event Service script on the Exchange folder to run when a new item is added to the folder.

--Sue Mosher
Bob Mills (not verified)
on Sep 15, 2000
I had the same experience. Every time I manually run the macro, it increments the count by one, but it never automatically increments with new mail.
Sven De Troch (not verified)
on May 5, 2001
And it's working fine with Outlook 2002 (?) also (the version included in Windows XP), however I had to enable the "run macro" feature in "macro security".
Thx.
Mike Iem (not verified)
on Sep 6, 2000
I installed it per the directions and when I run it from the tools Macros Macro menu, it adds one. But it doesn't increment as main starts coming in. I think some instructions are missing?
Craig Smith (not verified)
on Sep 28, 2000
I have never worked with VBA within Outlook. It appears this is client-side code, meaning that the "mileage" won't be tracked when the client isn't running. Is that an accurate observation? Any suggestions on how to track the number of messages received (on the server) even when the client isn't running?
Sven DE TROCH (not verified)
on Oct 26, 2000
It's working fine for me. Had to read the instructions twice, but it'sworking fine with the given info. Nice job!

Please or Register to post comments.

IT/Dev Connections Exchange Server

Las Vegas
September 30th - October 4th

Paul ThurottYou'll have the opportunity to experience:
• Future Deopyments
and Integrations
• Hybrid Deployments
• Exchange Online
• Windows 8 Deployment
and much more!

Come See Tony Redmond & Mark Minasi in Person!

Early Registration Now Open

Current Issue

May 2013 - The NameTranslate object is useful when you need to translate Active Directory object names between different formats, but it's awkward to use from PowerShell. Here's a PowerShell script that eliminates the awkwardness.

CURRENT ISSUE / ARCHIVE / SUBSCRIBE

Windows Forums

Get answers to questions, share tips, and engage with the Windows Community in our Forums.