[ Beneath the Waves ]

Dump Mailbox Item Data

article and software by Ben Lincoln


This is a script that I wrote back in 2007 when I was supporting a BlackBerry Enterprise Server at work. One of my many complaints about that software was that any time it encountered a fatal error processing an item in a user's Exchange mailbox, it would refer to it only by "Ref ID", a serial number that the BES tags mailbox items with. There was (is?) no official way to map these IDs to specific mailbox items, so narrowing down the source of a problem was extremely time-consuming. Various low-level tools (MFCMAPI, etc.) will allow an administrator to determine the Ref ID (or any other internal property of an item) by looking at a specific item, but don't provide a way to find an item by Ref ID.

This was complicated by the fact that (at least at the time), RIM's developers had specified the name of the property using an ANSI string, even though the Exchange spec has it defined as Unicode. So in most tools, instead of the actual name (PR_RIM_MSG_REF_ID), unreadable garbage would be displayed. In addition, calendar items had (have?) their Ref IDs stored in a completely different way.

This script will iterate through an entire mailbox and dump a tab-delimited text file containing (where applicable based on the item type) the name of the folder containing the item, the sender's display name, the recipient's display name, the subject, the sent and received timestamps, and the BES Ref IDs. There are two columns for Ref IDs, with the first being used for calendar items and the second being used for everything else. This was to keep the logic of the script simpler than if I'd tried to collapse them into one. Some combination of this data should allow an engineer or administrator to locate an item which shows up in the log files and correct or delete/recreate it.

The computer on which the script is executed must have the MAPI components installed. The easiest way to do this is to install the Exchange System Manager/MMC. It will run much faster if executed directly on the Exchange server where the target mailbox is located, and that server should already have the MAPI components as well.

This script must be executed from the command line using cscript, and is most useful when the output is redirected to a text file. The syntax in that case (assuming the working directory is where the script is located) would be:

cscript -nologo DumpMailboxItemData.vbs [SERVER] [MAILBOX] > [OUTPUTFILE]

For example:

cscript -nologo DumpMailboxItemData.vbs mailserver01 blincoln > blincoln_refids.txt

Thankfully, I don't support a BES anymore, so this script has not been tested against BES 5.x or newer. It will not work with any BES other than the Exchange edition. I have not tested it with Exchange 2007 or newer, although I believe it has been run successfully against an Exchange 2007 mailbox by others.

File Size Version Release Date Author
Dump Mailbox Item Data 3 KiB 1.2 2007-08-09 Ben Lincoln
[ Page Icon ]