Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  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 log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...

10 Reasons to Deploy Windows Vista

The decision to upgrade your XP systems to Vista is simple when you consider features such as easier backup, a great desktop search, and vastly improved security options. ...

10 Reasons Not to Deploy Windows Vista

The decision to upgrade to Vista has to make business sense, but many companies find the costs in training and application compatibility problems outweigh any benefits Vista brings. ...


Exchange Server and Outlook Whitepapers Protecting (You and) Your Data with Exchange Server 2007

StoreVault SnapManagers for Microsoft Exchange and SQL Server

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

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 Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

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 Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing