Search code examples
office-jsexchangewebservicesoutlook-web-addins

Outlook web add-in How to get customer properties via EWS in JS


How to get customer properties via EWS in JS if I saved them via Outlook JS. API

  1. I saved custom properties using the following JS code:

       Office.context.mailbox.item.loadCustomPropertiesAsync(callback);
    
          function callback(asyncResult) {
          var customProps = asyncResult.value;
          customProps.set("isSync", "test");
    
         // Save custom properties via JS API
         customProps.saveAsync(saveCallback);
        }
    
  2. Then I would like to get this custom prosperity via EWS.

Case 1:

   '<t:ExtendedFieldURI PropertySetId="cecp-my manifest" PropertyName="isSync" PropertyType="String"/>' 

Case 2:

   '<t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="isSync" PropertyType="String"/>' 

Both approaches does not work. How should I describe <t:AdditionalProperties>?

At the same time everything works if I use .Net:

 ExtendedPropertyDefinition extendedPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "cecp-my manifest", MapiPropertyType.String);
 var props = new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent, extendedPropertyDefinition);'

Solution

  • Your property definition should be

    '<t:ExtendedFieldURI DistinguishedPropertySetId="PublicStrings" PropertyName="cecp-my manifest" PropertyType="String"/>' 
    

    That will return all the custom properties (as a Json String) which isSync should be in if set.