'Get named MAPI Property from MailItem in C#

I'm developing an Outlook 2010 custom plugin in C#. This is my first time using C# (I'm a java guy normally).

There is a named (custom) MAPI property on a message that I would like to access and am having trouble doing so. My understanding is that in Outlook 2007 the PropertyAccessor object was introduced which allows easy access to named MAPI properties. I followed the instructions from the following documentation:

http://msdn.microsoft.com/en-us/library/ff868915.aspx

I can see the named MAPI property I want to access on the message using Outlook Spy. From Outlook Spy I can get the following information about the property:

GUID:    {00020329-0000-0000-C000-000000000046}
Tag num: 0x80BE0102
ID:      PR.AFU.MESSAGE.RETRIEVE.INFO
Type:    PT_BINARY

So I tried the following code (Object mail is a valid instance of MailItem):

mail.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/id/{00020329-0000-0000-C000-000000000046}/80BE0102");

This produces the following exception:

The property "http://schemas.microsoft.com/mapi/id/{00020329-0000-0000-C000-000000000046}/80BE0102" is unknown or cannot be found

So I'm wondering how to actually get this property? Am I forming the namespace reference incorrectly? Or do I need to use an approach as outlined in this example:

http://www.outlookcode.com/codedetail.aspx?id=1112

My understanding was that this was only necessary for pre 2007 versions of Outlook. Any help is much appreciated!



Solution 1:[1]

What happens if you try

mail.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x80BE0102");

?

Solution 2:[2]

Microsoft's MFCMapi is also a great tool to locate the DASL and view all MAPI properties.

Solution 3:[3]

OutlookSpy (I am its author) will give you the DASL property name in the DASL edit box in the IMessage window (select a message with the property set, click IMessage button, select the property, look at the DASL edit box)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yahia
Solution 2 SliverNinja - MSFT
Solution 3 Dmitry Streblechenko