OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
686 stars 95 forks source link

EWS support for shared mailbox #2740

Closed plamenbotev closed 2 years ago

plamenbotev commented 2 years ago

Hello,

We are testing the EWS services to get additional information for the messages in a shared mailbox and we see no issues. All tested operations so far are working as expected. However I have noticed in the documentation, that EWS are not supported for shared maiboxes: https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access?tabs=windows#rest-and-ews

Is it safe for us to use the EWS services in that scenario?

yatibawri1 commented 2 years ago

Shared mailboxes are not supported at this time, we only support Shared Folders/Delegate scenarios. An overview of what is not supported can be found here And if you're interested in enabling Delegate Scenarios in an Outlook add-in, documentation can be found here. One thing to note is that in a delegate scenario, you can't use EWS with the tokens currently provided by office.js API.

plamenbotev commented 2 years ago

Hello and thank you for your reply. If I understood correctly shared folders should be accessible using EWS? Currently what I have tested is to create a shared mailbox in a development tenant. The mailbox appeared automatically in my web and desktop clients. I loaded my addin in the context of the shared mailbox and executed successfully EWS requests with token obtained from the office.js API.

I will double check the documentation, that you have shared, but is my assumption correct, that the request is not guarantied to work properly in the future for the context that I have used it?

exextoc commented 2 years ago

@plamenbotev As the documentation said, we do not support EWS for shared mailbox and therefore we don't guarantee the result for it.

plamenbotev commented 2 years ago

@exextoc Thank you for your answer. Another question regarding the supported setups with the graph services, will they be working properly on hybrid setups? This is actually the main reason for me to test the EWS as a backup and fallback if the graph calls error out. We are trying to make our product backward compatible as much as possible after the discontinuation of the Outlook REST services in November.

exextoc commented 2 years ago

@plamenbotev Yes, it works in 365 and in preview for on-premises. You can find more detail in link below: https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access?tabs=windows

plamenbotev commented 2 years ago

Hello again @exextoc and thank you for answering my questions. I got the impression that Graph will not be working properly at some point for mailboxes that are on-prem in hybrid setups: https://techcommunity.microsoft.com/t5/exchange-team-blog/the-end-of-the-rest-api-for-on-premises-mailboxes-preview/ba-p/3221219

But perhaps I interpreted that incorrectly?

ivaylomitrev commented 2 years ago

A follow up question from me too.

From what I gather from this discussion and the links provided:

EWS:

Graph API:

Is any of my statements incorrect?

Also, does any API support shared mailboxes at all?

Thanks in advance!

JuaneloJuanelo commented 2 years ago

Hello,

We are testing the EWS services to get additional information for the messages in a shared mailbox and we see no issues. All tested operations so far are working as expected. However I have noticed in the documentation, that EWS are not supported for shared maiboxes: https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/delegate-access?tabs=windows#rest-and-ews

Is it safe for us to use the EWS services in that scenario?

@plamenbotev when you say that you are testing EWS services to get additional information for the messages in a shared mailbox with no issues, what specifically you mean? how are you testing this? EWS calls are blocked in Outlook Add-ins when they are activated in a shared folder or mailbox context, to be very precise you cannot use the Office.js makeEwsRequestAsync method in such conditions, that's why I am curious to learn what you mean by "its working with no issues" I am assuming you are using raw EWS wihtout Office.js, which is an option.

To add more details. This snippet (import with Script lab) will fail with an "API not supported for shared folders." error, when executed from an add-in activated in a shared folder or mailbox.

JuaneloJuanelo commented 2 years ago

A follow up question from me too.

From what I gather from this discussion and the links provided:

EWS:

  • works in hybrid and cloud
  • works for shared folders
  • does not work for shared mailboxes

Graph API:

  • works in hybrid and cloud at the moment
  • works for shared folders and shared mailboxes (in preview) for both cloud and hybrid
  • according to this article, Graph API will stop working for hybrid environments in 2023 and EWS must be used

Is any of my statements incorrect?

Also, does any API support shared mailboxes at all?

Thanks in advance!

@ivaylomitrev i think we need to differentiate an important aspect here. which is Calling EWS using Office.js vs Calling EWS without Office.js.

  1. Using EWS via Office.js you cannot do operations on shared folders or mailbox.
  2. Using EWS without Office.js is Universal. (works on hybrid, cloud, shared folders and mailboxes.
  3. Graph is Cloud. works with shared folders and mailboxes. Will stop working in Hybrid.

and i would add: what is in preview right now (but we are working on and will be available soon) is Outlook Add-in Activation in Shared Mailbox, in OWA. We do have support for it in Win32.

Hope this clarifies.

plamenbotev commented 2 years ago

@JuaneloJuanelo Hello and thank you for taking the time to look into our questions.

I have done the following steps to get information via EWS for mail sent to shared mailbox:

  1. Created shared mailbox in the exchange admin center using development tenant
  2. In delegation tab for the newly created shared mailbox added my mail in Read and manage (Full Access)
  3. In my web outlook client I have added the shared mailbox mail as new shared folder

I have executed the following code in the browser console directly for the test:

https://gist.github.com/plamenbotev/696e789129837deec299962a4193172c

The above code returns response successfully and has the shape below: Object { status: "succeeded", value: "..." }

However if the above snippet should not work, should I be able to execute the same request from our backend using token obtained from Office.context.mailbox.getCallbackTokenAsync and sent against Office.context.mailbox.ewsUrl?

Thanks in advance

JuaneloJuanelo commented 2 years ago

@JuaneloJuanelo Hello and thank you for taking the time to look into our questions.

I have done the following steps to get information via EWS for mail sent to shared mailbox:

  1. Created shared mailbox in the exchange admin center using development tenant
  2. In delegation tab for the newly created shared mailbox added my mail in Read and manage (Full Access)
  3. In my web outlook client I have added the shared mailbox mail as new shared folder

I have executed the following code in the browser console directly for the test:

https://gist.github.com/plamenbotev/696e789129837deec299962a4193172c

The above code returns response successfully and has the shape below: Object { status: "succeeded", value: "..." }

However if the above snippet should not work, should I be able to execute the same request from our backend using token obtained from Office.context.mailbox.getCallbackTokenAsync and sent against Office.context.mailbox.ewsUrl?

Thanks in advance

@plamenbotev Thanks for sending this detailed description. I am able to repro your behavior in Outlook for the Web. The behavior is inconsistent with the Win32 Outlook client where EWS calls are not allowed neither on delegates nor in shared mailboxes. This is a platform disparity issue and I am able to repro those. That been said, shared mailboxes is not officially supported yet in OWA, so this might be blocked in the future. We need to have a couple of discussions on the team to see how we will solve this.

I guess the main outcome of all this thread is 2 things:

  1. REST APIs will be supported for Add-in until end of support of Office 2019 MSI.
  2. If you want to make sure EWS works across platforms you need to make the calls not using Office.js. You should be able to execute the script as you describe in your last question.
JuaneloJuanelo commented 2 years ago

Nothing further to add on this thread. We ahve a follow up on adjusting this functionality upon support of shared mailboxes in OWA.

plamenbotev commented 2 years ago

@JuaneloJuanelo Yes, I think that we have a clear idea how to proceed. Thank you. :)