Office-js: Shared MailBox, OfficeJS saveAsync() returns a draft ID that is not permitted by the owner's mailbox

Created on 23 Apr 2020  ·  45Comments  ·  Source: OfficeDev/office-js


On our Outlook add-in for compose mode, we are using the Office JS API to save the email draft by calling Office.context.mailbox.item.saveAsync() then passing the result to

Office.context.mailbox.convertToRestId(
            results[0],
            Office.MailboxEnums.RestVersion.v1_0
          );

to obtain the _draft ID_

Expected Behavior


The draft ID provided should be accessible by the mailbox owner on MS Graph service

Current Behavior


code: 404
message: 404 ErrorInvalidMailboxItemId: "Item Id doesn't belong to the current mailbox."
status: “failed”

Steps to Reproduce, or Live Example



Add a shared mailbox:

  1. Find and Open a shared mailbox

Steps to reproduce:

  1. Create a new email in Outlook for Mac
  2. In the From field, select the shared mailbox
  3. Open and add-in's pane and try to call
    Office.context.mailbox.item.saveAsync()
  4. Pass the result from Office.context.mailbox.item.saveAsync() to
Office.context.mailbox.convertToRestId(
            results[0],
            Office.MailboxEnums.RestVersion.v1_0
          );
  1. Use that ID to make a graph call with the mailbox owners graph token . The call should error out with the following message 404 ErrorInvalidMailboxItemId: "Item Id doesn't belong to the current mailbox."

  • Additional details:

This flow use to work up until a day or two ago and this flow cureently works on Windows Outlook and Outlook Web Access with our web-addin

Context


Your Environment

  • Platform: Mac
  • Host: Outlook for Mac
  • Office version number: 16.34 (20020900)
  • Operating System: MacOS Catalina 10.15.4 (19E287)
  • Browser (if using Office Online): ______
Outlook in backlog product bug

Most helpful comment

@exextoc
From the docs (https://docs.microsoft.com/en-us/javascript/api/outlook/office.messagecompose?view=outlook-js-preview#getsharedpropertiesasync-callback-) this function is not supported on Mac Outlook

I have tried with the following:
API set: Mailbox 1.8 is met
Mac Outlook: Insider Build 16.40 (20071407)
Office JS 1.1.40

The following call returns an undefined function

Office.context.mailbox.item.getSharedPropertiesAsync(function(result) {
  console.log(result.value);
});

All 45 comments

I have the above issue as well, tunning running macOS 10.15.4 and outlook version 16.36 (20041300)

I experienced the similar issue. Outlook Version 16.36 (20041300).

Did you start facing this issue after upgrading to MacOS Catalina 10.15.4?

Did you start facing this issue after upgrading to MacOS Catalina 10.15.4?

We are not certain if upgrading to MacOS Catalina 10.15.4 (19E287) was the issue. Something that is worth mentioning is that on another Mac that I have which is on MacOS Catalina 10.15.4 (19E266) was working last week, however when trying again today it doesn't work anymore.

We got another team member to test with macOS Mojave Version 10.14.6 with Outlook Version 16.36 (20041300) and it doesn't work as well

Can you try to get the message via Rest API as mentioned in doc using postman app and see if you are able to access the item.
Also when you say mailbox owner is it owner of shared mailbox or the person whom mailbox is delegated to?

@exextoc
We are trying to retrieve the draft from the delegated mailbox via Graph, as suggested we have also tried calling the Rest API with the draft id and the result is the same as the error we have provided in this issue. The draft id we obtain from OWA or Windows Outlook is working, but the draft ID we are getting back on Mac is not working.

@exextoc Can you provide a timeline on a fix for this?

Could you please share the code snippet used to retrieve the draft? We would also like to understand what is the rest URL being used to retrieve the draft item.

Could you please share the code snippet used to retrieve the draft? We would also like to understand what is the rest URL being used to retrieve the draft item.

The gist of the code snippet is as follow:

Office.context.mailbox.item.saveAsync(function(result) { 
  var promises = [];
  promises.push(result.value);

  Office.Promise.all(promises).then(
    function(results) {
      var draft_id = Office.context.mailbox.convertToRestId(
        results[0],
        Office.MailboxEnums.RestVersion.v1_0
      );
    },
    function(err) {
      // handle error
    }
  );
});

We then use the draft_id to call graph api with.

We are using:

https://graph.microsoft.com/v1.0/users/<:id>/mailFolders/<:id>/messages/<:draft_id>?$expand=attachments

Please keep in mind that this flow does work with our addin with OWA and Outlook for windows.

@exextoc

Could you please share the code snippet used to retrieve the draft? We would also like to understand what is the rest URL being used to retrieve the draft item.

The gist of the code snippet is as follow:

Office.context.mailbox.item.saveAsync(function(result) { 
  var promises = [];
  promises.push(result.value);

  Office.Promise.all(promises).then(
    function(results) {
      var draft_id = Office.context.mailbox.convertToRestId(
        results[0],
        Office.MailboxEnums.RestVersion.v1_0
      );
    },
    function(err) {
      // handle error
    }
  );
});

We then use the draft_id to call graph api with.

We are using:

https://graph.microsoft.com/v1.0/users/<:id>/mailFolders/<:id>/messages/<:draft_id>?$expand=attachments

Please keep in mind that this flow does work with our addin with OWA and Outlook for windows.

@exextoc Have you replicated the issue? We need a fix for this as soon as possible. Let me know if you need additional details.

We are able to repro this issue from our side when the user id in the graph call is the delegatee's Account. Can you confirm the user id being used here?

We are able to repro this issue from our side when the user id in the graph call is the delegatee's Account. Can you confirm the user id being used here?

Yes, this is correct. The user id used in the graph call is the delegate's account.

@exextoc When can we expect this to be resolved?

Using getSharedPropertiesAsync is the solution here, our team is working towards enable this API on Outlook for Mac. It should be available in Insider builds soon.

@exextoc

Thank you for the update. As our clients rely on this web add-in for their day to day business is not on board with using insider builds, can you provide an approximate timeline on when this will be available on the next insider build and release so we can start working on using getSharedPropertiesAsync()? In the future in case of a breaking change like this one, please communicate this to us in advance so we can have enough time to respond and find potential solutions or a work around.

@exextoc Do you have an ETA on this fix?

We unfortunately have no timelines to share at this point. Thanks a lot for your patience.

@exextoc Do you have any updates regarding this? Our customers have not been able to use our Add-in on their Mac version of Outlook for 6 weeks now.

@exextoc Do you have updates here? This functionality had never been an issue up until April this year.

Hi @liamtim , unfortunately support for getSharedPropertiesAsync has still not rolled out to Insiders. We are working on rollout, but cannot share timelines at this point. Thank you for your patience. We will update this thread once it is available.

Update: getSharedPropertiesAsync has been rolled out to Insiders. You should be able to use the API on the latest Insider Fast build. It will be rolled out to non-Insider builds soon.

@exextoc
From the docs (https://docs.microsoft.com/en-us/javascript/api/outlook/office.messagecompose?view=outlook-js-preview#getsharedpropertiesasync-callback-) this function is not supported on Mac Outlook

I have tried with the following:
API set: Mailbox 1.8 is met
Mac Outlook: Insider Build 16.40 (20071407)
Office JS 1.1.40

The following call returns an undefined function

Office.context.mailbox.item.getSharedPropertiesAsync(function(result) {
  console.log(result.value);
});

@exextoc Can you provide some insight here please?

I'm hitting this issue with as well, on the insider build for Outlook for Mac

getSharedPropertiesAsync has been rolled out to Insiders and is available in latest IF build 16.40 (20071407). But, the issue reported is reproducible in Message Compose surface alone while it works as expected on other surfaces. Can you confirm this on your side?

getSharedPropertiesAsync has been rolled out to Insiders and is available in latest IF build 16.40 (20071407). But, the issue reported is reproducible in Message Compose surface alone while it works as expected on other surfaces. Can you confirm this on your side?

We currently only use the library in compose mode for Outlook, therefore we are not certain if it works on other surfaces or not. Compose surface is what we are concerned at the moment, which unfortunately doesn't work.

Thanks for confirming that you are seeing this issue in Message Compose surface. It has been put on our backlog. We unfortunately have no timelines to share at this point.

@exextoc Can this issue be reopened? or is there another issue we can follow along here?

We will update this thread once the issue is fixed.

Internal tracking id: Office:4312812

@exextoc Is there any way to bump the priority on this issue? It was initially reported that the function does not work when using Compose mode via Mac OS 3 months ago

@exextoc Can you please provide an update here? Our customers have not been able to use our Add-in on their Mac version of Outlook for 14 weeks now.

@macOutlookExtensibility Do you have any updates for us here?

@exextoc @macOutlookExtensibility Can you provide us with an update? We are without this functionality for 3.5 months now.

Apologies for this delay. We are actively working on this and will be able to provide update soon on this.

@exextoc Thank you for confirming. Looking forward to receiving a timeline.

@exextoc, any updates on a timeline for this?

I'm also still hitting the same issue from before. It'd be great to see this fixed!

The support for getSharedProperties in MessageCompose Scenario is added and it is in Insiders fast now.
With this getSharedPropertiesAsync API you will get the params targetRestUrl , targetMailBox which you can use to construct rest url and get the required information.

@exextoc
I have tried using the getSharedPropertiesAsync API which is now available in the insiders fast build from following the example in the docs https://docs.microsoft.com/en-us/javascript/api/outlook/office.messagecompose?view=outlook-js-preview#getsharedpropertiesasync-options--callback-

However, I am getting a http response of 403. The only thing different on my end is, I am doing this in compose mode, therefore I am not using this var ewsId = Office.context.mailbox.item.itemId; from the docs to get the itemId, instead Office.context.mailbox.item.saveAsync is used to get the identifier as suggested here in the docs https://docs.microsoft.com/en-us/javascript/api/outlook/office.messageread?view=outlook-js-1.8#itemid

PS. Both delegatePermissions and Office.MailboxEnums.DelegatePermissions.Read is 1

What would cause this 403 Forbidden status to return?

sharedProperties.targetRestUrl + "/v2.0/users/" + sharedProperties.targetMailbox + "/messages/" + draft_id; which translates into https://outlook.office.com/api/v2.0/users/[email protected]/messages/<:draft_id> would return a status of 403 Forbidden. I am using the (token asyncContext) from the result of getSharedPropertiesAsync, for the rest call.

Please help us resolve this issue, as we have tried this API several times with similar result.

I've been following this thread as well, I still have the problem as described by @naemcivic even on insiders build

@exextoc thank for update. But still have issues as @naemcivic mentioned. Fast build not quite works.

@exextoc @macOutlookExtensibility

Is there any update on this please. would really like to get this to be sorted out, as this has been on going for so long. thank you

Was this page helpful?
0 / 5 - 0 ratings