locked
User Properties vs MAPI ExtendedPropertyDefinition RRS feed

  • Question

  • What is the difference between Extended Properties Definition created with EWS Managed API and User properties created with the outlook addin. 

    I can write a custom property like this using the  EWS Managed API:

         private void setProperty(Item item, Property prop) { 

             item.Load();

              item.SetExtendedProperty(Prop.name, Prop.value); 

              ConflictResolutionMode mode = ConflictResolutionMode.AlwaysOverwrite; 

              item.Update(mode); 

          } 

    Where Prop is an object, that contains an Extended Property definition and object value:

    ExtendedPropertyDefinition prop = new ExtendedPropertyDefinition(

    DefaultExtendedPropertySet.PublicStrings, "Prop", MapiPropertyType.String);

    Inside of the Outlook Add-In User Properties are set using this method:

    mailItem.UserProperties.Add("PropName", Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText).Value = PropValue;

    In EWS Managed API how do you access these properties set in the outlook addin? 

    Second Question:

    These properties set using the UserProperties, Add method, persist on message send. Do properties set to a mailItem using SetExtendedProperty, of EWS persist across message send. If not what property can be used to do so? 


    Milton Cody

    Tuesday, August 25, 2015 3:23 PM

All replies

  • User properties are just Extended MAPI properties so there is no difference at that level and in regards to persistence, to access them in EWS you need to define the property you want to use, Add it to a property set and then load that property set. eg

                ExtendedPropertyDefinition prop = new ExtendedPropertyDefinition( DefaultExtendedPropertySet.PublicStrings, "Prop", MapiPropertyType.String);
                PropertySet PropSet = new PropertySet(BasePropertySet.FirstClassProperties) { prop };
                Message.Load(PropSet);
                Object Propval = null;
                if (Message.TryGetProperty(prop, out Propval))
                {
                    Console.WriteLine(Propval);
                }

    The only difference when using these properties is that properties added via EWS aren't added the UserProperties Blob which is described in https://social.technet.microsoft.com/Forums/office/en-US/2a98b4ab-0fbc-4863-8303-48711a18a050/custom-properties-added-by-ews-not-visible-in-outlook?forum=exchangesvrdevelopment which just means you always need to use the PropertryAccessor in OOM if this is the way your using them.

    Cheers
    Glen


    Wednesday, August 26, 2015 5:08 AM