Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


September 2000

Tracking Your Email Mileage


RSS
Subscribe to Windows IT Pro | See More Exchange Server and Outlook Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

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.

End of Article



Reader Comments
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?

Mike Iem September 06, 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.

Bob Mills September 15, 2000


The code works fine for me. I think you will find after you
close and restart Outlook you'll have better luck.


Stephen Whiteley September 20, 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?

Craig Smith September 28, 2000


It's working fine for me. Had to read the instructions twice, but it'sworking fine with the given info.
Nice job!

Sven DE TROCH October 26, 2000


<i>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.</i><br><br>
--Sue Mosher

Sue Mosher April 20, 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".
<br>
Thx.


Sven De Troch May 05, 2001


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

DWH March 29, 2003


You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...

2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...


Exchange Server and Outlook Whitepapers Email Controls and Regulatory Compliance

Take Control of Your Email: Understand the Business Reasons for Email Storage Management

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Bail Out Your Exchange Environment

Check out our list of Free Email Newsletters!

Exchange Server and Outlook eBooks Spam Fighting and Email Security for the 21st Century

Understanding and Leveraging Code Signing Technologies

The Expert's Guide for Exchange 2003: Preparing for, Moving to, and Supporting Exchange Server 2003

Related Exchange Server and Outlook Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format

Exchange & Outlook UPDATE eNewsletter
News, strategies, products, and developments in Exchange Server and Outlook messaging.

Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement