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

API to fetch mail body Office.context.mailbox.item.body.getAsync() returns different result when called in succession on MAC Outlook application #4894

Open pza-dev-brcm opened 1 month ago

pza-dev-brcm commented 1 month ago

We are using ItemSend event in outlook add-in. We monitor email content like subject, body, recipients, attachments and based on policy we decide whether to allow or block the email to be sent.

For optimisation, we are handling OnMessageAttachmentsChanged event too in add-in. As a result, when user attaches any file to email we get callback and we do some processing as per business logic.

As a precautionary measure, we need to check mail body twice in succession at different time interval. If body is changed we don't allow mail to be sent.

For fetching mail body we use below API API to get body type: Office.context.mailbox.item.body.getTypeAsync() API to get actual body based on body type: Office.context.mailbox.item.body.getAsync(bodyType, function())

There is no issue with this approach/API on Windows classic/new outlook. OWA also works fine on Windows and Mac. Only in case of MAC outlook applications, Office.context.mailbox.item.body.getAsync() API is returning different body contents when called in succession, even though mail contents are not modified.

Expected result: Office.context.mailbox.item.body.getAsync() API should return same content as a result, if mail is not modified and we are calling this API in succession.

Your Environment Platform [PC desktop, Mac, iOS, Office on the web]: PC Desktop Host [Excel, Word, PowerPoint, etc.]: New Outlook Office version number: Microsoft Outlook Version 1.2024.814.200 (Production) | Client Version is 20240809006.12 | WebView2 Version is 127.0.2651.105 Operating System: Windows11 Browser (if using Office on the web): Chrome

pza-dev-brcm commented 1 month ago

CheckBody.zip

Please find sample attached add-in for reproducing the issue. Please update correct path in xml where you are actually going to host this add-in.

pza-dev-brcm commented 2 weeks ago

Hi Any updates on the same ?