Eugene Astafiev

How to get access to hidden Outlook items via Extended MAPI?

MAPI (also known as Extended MAPI) is a powerful and complex COM-based API developed for creating mail-enabled applications. Microsoft Outlook and Exchange are among the most popular applications utilizing MAPI. Add-in Express provides Outlook developers with a free component, MAPI Store Accessor, that hides MAPI complexities to provide developers with easy access to MAPI features. One of them is hidden items.

Hidden items in Extended MAPI

Storing some application-specific data between sessions is quite a usual task for Outlook developers. Such data are store either in the Windows registry or just in a file (binary or text, custom format or XML).

The MAPI subsystem provides yet another possibility: it allows you to create and save any data in hidden items. As the name suggests, a hidden item isn’t visible in Outlook. Hidden items are similar to usual mail, contact, and task items because they have the same properties: subject, body, attachments, etc. Also, you can find the term “associated content” in various information sources which has exactly the same meanings.

As an example of this approach, Outlook saves folder view settings in hidden items. Views, custom form definitions, archive settings, and many other configuration options can be stored in such hidden items. In Outlook 2007, you can find the StorageItem class that describes a hidden item.

MAPI Store Accessor provides an easy access to this feature of MAPI through the HiddenMapiItems property of the AddinExpress.MAPI.Folder class. To demonstrate the use of this property, I developed a small application that creates a new MAPI session for the default MAPI profile and show the following form:

Create, view, and delete hidden Outlook items with a simple application.

The form allows choosing a folder name in order to see its hidden items. In the list box, I show the subject and the class name of hidden items.

You can create such an item and use standard and / or custom properties to store your data.

To set a value of some standard property in the SetProperty method, you use the corresponding property tag from the AddinExpress.MAPI.ADXMAPIPropertyTag enumeration.

To create a custom property you have to combine a property type with a property ID into the property tag. For example, consider the following code:

C#:

mapiItem.SetProperty(0x340F0003, myLongValue);

VB.NET:

mapiItem.SetProperty(CType(&H340F0003, UInteger), myLongValue)

The first parameter of the SetProperty method is a property tag. The first part of the property tag is a property ID (0x340F) and the second one is a property type. In this case the property type is PT_LONG (0x0003).

Extended MAPI allows you to choose an ID for your custom property from the predefined ranges of values. The ranges are listed in the MAPITags.h file. Here they are:

The following ranges should be used for all property IDs. Note that property IDs for objects other than messages and recipients should all fall in the range 0x3000 to 0x3FFF:

From To Kind of property
0001 0BFF MAPI_defined envelope property
0C00 0DFF MAPI_defined per-recipient property
0E00 0FFF MAPI_defined non-transmittable property
1000 2FFF MAPI_defined message content property
3000 3FFF MAPI_defined property (usually not message or recipient)
4000 57FF Transport-defined envelope property
5800 5FFF Transport-defined per-recipient property
6000 65FF User-defined non-transmittable property
6600 67FF Provider-defined internal non-transmittable property
6800 7BFF Message class-defined content property
7C00 7FFF Message class-defined non-transmittable property
8000 FFFE User-defined Name-to-id mapped property

The 3000-3FFF range is further subdivided as follows:

From To Kind of property
3000 33FF Common property such as display name, entry ID
3400 35FF Message store object
3600 36FF Folder or Adderess Book container
3700 38FF Attachment
3900 39FF Address book object
3A00 3BFF Mail user
3C00 3CFF Distribution list
3D00 3DFF Profile section
3E00 3FFF Status object

Find more about MAPI property tags on MSDN.

Available downloads:

These sample COM Add-ins were developed using Add-in Express for Office and .net:

C# sample Outlook add-in
VB.NET sample Outlook add-in

6 Comments

  • https://secure.gravatar.com/avatar/71c834e0ffdb40ed30186a5debcda70a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Kevin says:

    I tried to use the MAPI Store Accessor but am using Microsoft Visual C# 2010 Express, which is not provided as an option during install. Is it possible to use this component with VS Express?

  • https://secure.gravatar.com/avatar/bbd979ae5b772d0bc1f82065aa4ba146?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Eugene Astafiev says:

    Hi Kevin,

    No, it is not. The Express editions of Visual Studio are not supported by the MAPI Store Accessor installer. Instead, I can send you the dll without an installer. Does it suit your needs? Which e-mail address should I use?

  • https://secure.gravatar.com/avatar/ae385b6a235545981539e84724512e14?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G martin says:

    Hello,
    can I use mapi store accessor without using the installer.
    I want to run it in a service on a machine without visual studio installed?
    Thanks for help
    Martin

  • https://secure.gravatar.com/avatar/bbd979ae5b772d0bc1f82065aa4ba146?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Eugene Astafiev says:

    Hello Martin,

    Please note that you don’t need to have Visual Studio installed on the target PC. Do you get any error messages or exceptions?

  • https://secure.gravatar.com/avatar/e0b8284d81edc19cec78d0f63a630039?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Kushan Randima says:

    Hi,

    After googling for quiet a lot of resources, I believe that I can’t use “MAPI Store Accessor” with Visual Studio 2013 & Add-in express v.7.7.4087. I need to set some extended properties. How I do that? Please explain.

    Thank You.

  • https://secure.gravatar.com/avatar/29957f26ad2d8ba527fd9cc8cfa7b2e0?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G Andrei Smolin (Add-in Express Team) says:

    Hello Kushan,

    > I believe that I can’t use “MAPI Store Accessor” with Visual Studio 2013 & Add-in express v.7.7.4087

    Correct.

    You use the StorageItem object, see https://msdn.microsoft.com/en-us/library/office/ff864182%28v=office.15%29.aspx. To set the MAPI properties that the Outlook object model doesn’t let you modify, see the PropertyAccessor property.

Post a comment

Have any questions? Ask us right now!