Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

July 24, 2000 08:20 AM

Tracking Your Email Mileage

Windows IT Pro
InstantDoc ID #9167
Rating: (0)
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.

Related Content:

ARTICLE TOOLS

Comments
  • dwh
    9 years ago
    Mar 29, 2003

    Works great in XP - many thanks for a neat solution...

  • Sven De Troch
    11 years ago
    May 05, 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.

  • Sue Mosher
    11 years ago
    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

  • Sven DE TROCH
    12 years ago
    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!

  • Craig Smith
    12 years ago
    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?

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.