Search code examples
office-jsoutlook-addinoutlook-web-addins

Outlook: How to get from email-ID the "itemId" to use in office.js.api?


I am developing add-in for outlook(web and desktop).For that I am using office.js.api for rest calls. One of the core functionalities of my add-in is reminder. User sends emails and add-in tracks that email id(it adds it to DB). I want user to have option on pressing btn to open in new window needed email.

What i know:
To open emails in new window I need to use displayMessageFormAsync method from office.js.api. But here is a problem as input it needs ItemId not messageId.

So question is how to convert messageId to ItemId?

Example of messageId: AQMkADAwATMwMAItNGIxMy0yYTAyLTAwAi0wMAoARgAAA5vuE8DX1vtBmAIURe25AdEHAENSlH9y8y9Jqcjhmi7n76AAAAIBDwAAAENSlH9y8y9Jqcjhmi7n76AAAAAGaAVeAAAA
How it looks like in code

let tmp2='AQMkADAwATMwMAItNGIxMy0yYTAyLTAwAi0wMAoARgAAA5vuE8DX1vtBmAIURe25AdEHAENSlH9y8y9Jqcjhmi7n76AAAAIBDwAAAENSlH9y8y9Jqcjhmi7n76AAAAAGaAVeAAA'

Office.context.mailbox.displayMessageFormAsync(tmp2, function (asyncResult) {
                           console.log("Result: " + JSON.stringify(asyncResult));
                          });

but if I pass as arg to method messageID it throws error in console error image


Solution

  • So messageID are itemID but here is a trick. ItemId changes for an item when it is moved from one folder to another and it will not be constant on folder movement As suggested Outlook Add-ins Team - MSFT need to use immutable ids and somehow GRAPH API `