Using Office.js API we can easily save extra info to the CustomProperties
object via customProps.set
. The information is specific to the mail item.
The is the doc Save to custom properties using office.js
Can I achieve the same thing using EWS
API?
I tried Creating custom extended properties by using the EWS Managed API 2.0 But whatever info saved via this method I cannot retrieve it using Office.js 's customProps.get
.
The User case is that my add-in will save the email body and its attachments binary to the external application. Upon finish the client side will use Office.js 's customProps.set
to save the success info to the server, and if you click the same email next time the app will use customProps.get
to show you the email has been saved. But if during the lengthy save process(maybe save a big attachment, the user close the task pane, before the customProps.set
is executed, the customProps.set
will simply not fire because the browser environment (task pane) is closed. So I need to implement this using EWS's API.
My C# code:
Guid PS_PUBLIC_STRINGS = new Guid("a8e14732-37cf-4a46-b69f-1111111111");//add-in manifest id
ExtendedPropertyDefinition extendedPropertyDefinition =
new ExtendedPropertyDefinition(PS_PUBLIC_STRINGS, "Expiration Date", MapiPropertyType.String);
Email.SetExtendedProperty(extendedPropertyDefinition, DateTime.Now.AddDays(2).ToString());
Email.Update(ConflictResolutionMode.AlwaysOverwrite);//'The requested web method is unavailable to this caller or application.'
JS Code:
Office.context.mailbox.item.loadCustomPropertiesAsync(function (asyncResult) {
var customProps = asyncResult.value;
console.log(customProps);
console.log(customProps.get('Expiration Date')); //undefined
})