1

The scenario is this: have an app which exports to Outlook and then have an Outlook add in which sends data to your app. It is easy enough to send info either way and then in Outlook to create an Outlook item with a user property or in the app to create the item using EWS and use the extended properties.

The way to set the extended property is as follows:

    extendedPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "CustomProperty", MapiPropertyType.String);
    contact.SetExtendedProperty(extendedPropertyDefinition, customPropertyValue);

So how do you access the extended properties set by your app (using EWS) in the Outlook add in?

Marc K
  • 392
  • 3
  • 11

1 Answers1

3

In the add in, one does not simply find this property defined as a UserProperty. Therefore the property needs to be accessed using the PropertyAccessor, for which you need the schema of the extended property. This is not easy to find in online documentation, but I managed to find out that the schema for these PublicStrings extended properties is:

"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/CustomProperty"

Note that if you use the PropertyAccessor and the property does not exist on the Outlook item, a COM exception will be thrown, so a try-catch is necessary in order to return an empty value.

crthompson
  • 15,653
  • 6
  • 58
  • 80
Marc K
  • 392
  • 3
  • 11
  • 1
    You can see the property and its DASL name in OutlookSpy(http://www.dimastr.com/outspy) - select the message with the property, click IMessage button, select the property, see the DASL edit box. Note that it is a good idea to include the property type in the DASL name. – Dmitry Streblechenko Nov 19 '13 at 18:00
  • Hi. Thanks. Yes - Outlook spy will definitely work well here. I highlighted this specific id because it would be used more commonly like this than other ids. Also I wanted to highlight that this could have been well documented somewhere easy to find. It would have made sense if on the item one could just do this: `item.PropertyAccessor.GetProperty(ExtendedPropertyType.PublicStrings, "CustomProperty")` – Marc K Nov 21 '13 at 06:14
  • You cannot have just an enum (PublicStrings). You can use any GUID, and that what the DASL property name is for. – Dmitry Streblechenko Nov 21 '13 at 07:06
  • I know, but there could also be a constructor to specify a Guid. I'm working on this solution currently. – Marc K Nov 22 '13 at 07:31
  • Really REALLY helpful, after hours of searching, thank you! – OverMars May 10 '18 at 18:09