Jérôme Pott
Jérôme Pott

Reputation: 185

How to get the values of column fields in Outlook with office.js?

In Outlook, users can add built-in (email size, importance, etc.) or custom columns that will appear in their inbox view. (https://support.office.com/en-us/article/add-or-remove-columns-in-the-inbox-78098e3e-8203-47da-815e-cb66f76b512e)

How can I read their values? For example, how can I get the email size? Or how can get the value of a custom column?

I've read the whole documentation reference of Outlook Javascript API, but I couldn't find anything.

Categories and CustomProperties are not what I am looking for.

I hope somebody can help me 🙇‍♂️

Upvotes: 0

Views: 212

Answers (2)

user7823505
user7823505

Reputation:

These properties are not directly available through add-in APIs. You can use the makeEwsRequestAsync API to make a call to the Exchange backend, and use the GetItem EWS Operation to get properties of the message. Modify the ItemShape element to specify the properties you need.

Note that your add-in must specify the ReadWriteMailbox permission in its add-in manifest.

Upvotes: 1

Ruckert Solutions
Ruckert Solutions

Reputation: 1301

I used the ews-javascript-api library. (There is ews-js-api-browser for use in browser)

This allows to load the info related to the item pretty easy.

const loadedItem = await exch.BindToItems(
      [new ewsjs.ItemId(Office.context.mailbox.item.itemId)],
      new ewsjs.PropertySet(
        ewsjs.BasePropertySet.FirstClassProperties,
        ewsjs.EmailMessageSchema.Size,
      ),
    )

If you do not wanna use the library you have to write EWS requests yourself as explained here in the docs.

Upvotes: 1

Related Questions