I have built an addin that download a selected message in outlook. It works great with user's mailbox, however when it comes to emails in shared folder things are getting complicated.
I'm using following API to download an email
https://outlook.office365.com/api/v2.0/users/${sharedfolder-email}/messages/${id}/$value
and I can't figure out how to get an ${sharedfolder-email} or ID.
Here is a snippet how I get required data to download email using JavaScript API
Office.context.mailbox.getCallbackTokenAsync(function(result) {
if (result.status !== "succeeded") {
printError(outputEl, "Error happened (accesss token was not issued), try again or contact support");
return;
}
var token = result.value;
var ewsurl = Office.context.mailbox.restUrl;
var ewsItemId = Office.context.mailbox.item.itemId;
var isFromSharedFolder = Office.context.mailbox.initialData.isFromSharedFolder
const itemId = Office.context.mailbox.convertToRestId(ewsItemId, Office.MailboxEnums.RestVersion.v2_0);
...
}
I have a flag isFromSharedFolder that indicate if an item belongs to SharedFolder but I can't find out to what folder it actually belongs.
Do I miss something? Please help :-)
To get the email address of the Shared Folder, you can use this API:
Office.context.mailbox.item.getSharedPropertiesAsync
This will return an Office.SharedProperties object that contains the targetMailbox
which is the email address of the Shared Folder where the item is located.
Further documentation can be found here: https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access?tabs=windows%2Cxmlmanifest
One more thing: Office.context.mailbox.initialData.isFromSharedFolder
is not an API. Instead, use the getSharedPropertiesAsync
API.