Skip to content

Querying ExtendedProperty

Ivan Franjic (EXCHANGE) edited this page Aug 22, 2019 · 1 revision

Some of properties that are part of the object aren't exposed to the caller through common schema. Fortunately, if necessary, caller can request those properties by specifying MapiPropertyTag.

Below is example how to retrieve RetentionTag from an item.

ExchangeServiceContext ctx = new ExchangeServiceContext(
    new TestAuthenticationProvider());

ExchangeService service = ctx["[email protected]"];
SearchFilter isequalto = new SearchFilter.IsEqualTo(
    MessageObjectSchema.Subject, 
    "Hello!!");

MessageView view = new MessageView();
view.PropertySet.Add(
    new ExtendedPropertyDefinition(MapiPropertyType.Binary, 0x3019));

foreach (Message message in await service.FindItems(WellKnownFolderName.Inbox, view, isequalto))
{
    Console.WriteLine("PropId: {0}\r\nPropValue: {1}",
        message.SingleValueExtendedProperties[0].Id,
        message.SingleValueExtendedProperties[0].Value);
}

If message contains retention policy tag, this will be output of above snippet:

PropId: Binary 0x3019
PropValue: XHQmLWaFw02Ft6iPVkQ7ew==