Search code examples
outlook-addinoffice-jsoffice-js-helpers

Get all available values in Office.context.mailbox.item for Outlook


Is there an api to access get all available values async in Office.js, specifically Office.context.mailbox.item in Outlook?

I do not see anything in the docs.

I need to capture 10 or so fields, and to date have only implemented with callbacks, e.g.

var ITEM = Office.context.mailbox.item;
var wrapper =  //fn to parse results and call next field getAsync as cb
ITEM.end.getAsync(wrapper);

Solution

  • The documentation reference you have provided stated the Office.context.mailbox.item is the namespace. The namespace don't have the method which would enumerate all other methods in the namespace and return some consolidated result, instead you would use specific method, get the result and move to the next method you are interested in. This is all Office.js API offered for the item.

    If you need to get several item properties at once, you may look at EWS request support of Office.js API by calling to Office.context.mailbox.makeEwsRequestAsync. Inside your XML request you may specify fields you are interested in and retrieve them with one request/response. Refer to Call web services from an Outlook add-in article for more information.

    Yet another option to get several item properties at once is to Use the Outlook REST APIs from an Outlook add-in