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
690 stars 95 forks source link

Adding recipient in OnMessageSend times out the add-in #5132

Open avisheknand opened 5 days ago

avisheknand commented 5 days ago

We would like to add a recipient to the email on the OnMessageSend event. When we do so, the event.completed executes but still shows the Addin is processing and times out. Can we add recipients in OnMessageSend event?

This issue happens on OWA , New Outlook for Windows. It works fine on the Classic Outlook for Windows

Your Environment

Below is the code i have: image

Below is the behavior when sending email image

pepso commented 4 days ago

@avisheknand It's possible you hit this bug (the right hand side / yellow warning): https://github.com/OfficeDev/office-js/issues/4669#issuecomment-2326061973

Try to remove the recipient launch event and see if that fixes the issue to confirm the root cause.

While your onMessageSendHandler is being executed, the add recipient triggered another launch event (OnMessageRecipientsChangedHandler), which invalidated the event handler context your onMessageSendHandler is trying to call to complete the event before it got that far.

avisheknand commented 3 days ago

@pepso,I guessed that as well. It seems the OnMessageRecipientsChangedHandler is causing a conflict. The only way to make it work is to completely remove the event from the manifest file: <LaunchEvent Type="OnMessageRecipientsChanged" FunctionName="OnMessageRecipientsChangedHandler" />. When I removed it from the manifest, I was able to add the recipient via the onMessageSend event. Note: Commenting out the OnMessageRecipientsChangedHandler in the JS will not work; it needs to be completely removed from the manifest.

It’s strange that it works fine in Classic Outlook without removing the handler, but Classic Outlook uses a different environment to run this event compared to New Outlook and OWA.

shighosh-msft commented 1 day ago

Thanks for bringing this to our attention. We are currently investigating the issue and have included a work item in our backlog to resolve it. We have actively prioritized launch event improvements for this semester (ending Mar 25) to address similar issues. We expect this to be resolved over the next few months, once we have clarity on the root cause and a path to resolution. In the meantime, could you please confirm the following: Is this a regression i.e. did this work previously or New Outlook/OWA? If yes, since when are you seeing the regression on New Outlook/OWA? As always, we value your partnership with our team as we work towards improving our Office JS APIs on Outlook.