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
641 stars 92 forks source link

Integrated spam-reporting add-in: Office.context undefined #4411

Closed navmro closed 3 days ago

navmro commented 2 weeks ago

Provide required information needed to triage your issue

Now that the feature for "integrated spam-reporting add-in" is also in preview for the new Outlook we're trying to have it work there. The plugin appears, the popup appears, but then timeout due to an undefined variable.

Your Environment

Expected behavior

After the popup appears when the user report an email, the "onSpamReport" callback should be called.

Current behavior

In the new Outlook on Windows, the popup appears, but when the button is clicked it spins until timeout:

Opening the plugin in the web version on https://outlook.office.com/ (not my targeted environment). We can see an error in the debugger when the button is pressed:

"Cannot read properties of undefined" For Office.context.platform

The bit of code where the error is come from the plugin : https://github.com/OfficeDev/Office-Add-in-samples/blob/main/Samples/outlook-spam-reporting/src/spamreporting.js#L41 And from the documentation: https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/spam-reporting#implement-the-event-handler

Steps to reproduce

I've used both the Sample "integrated spam-reporting addin":

  1. Deploy https://github.com/OfficeDev/Office-Add-in-samples/tree/main/Samples/outlook-spam-reporting
  2. Open new Outlook
  3. Press the button to report an email as spam
  4. Press the "Report button" in the popup

Or my sample plugin (https://github.com/navmro/antiphishing) which is just following documentation:

  1. Create a new Outlook plugin with "yo office"
  2. Follow the documentation from : https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/spam-reporting
  3. npm start
  4. Press the button to report an email as spam
  5. Press the "Report button" in the popup

Both have the same code, coming from the documentation.

Provide additional details

  1. I've enabled "EnableBetaAPIsInJavaScript" to 1 in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Outlook\Options\WebExt\Developer
  2. I've tried with the user or with the whole tenant in "targeted release" in the M365 console

Removing the if (Office.context.platform === ... check allows the plugin to move forward, the callback is called. But then fails later with an error: Error encountered during message processing: The operation is not supported. from: https://github.com/OfficeDev/Office-Add-in-samples/blob/main/Samples/outlook-spam-reporting/src/spamreporting.js#L14 I've not investigated that yet.

Context

We're trying to replace our existing VSTO spam-reporting addin with a new one that would work in the new Outlook.

The new JS plugin works on the old outlook desktop app, but not in the new Outlook desktop app.

Useful logs

The logs on chrome were already provided above.

For the new Outlook on desktop, no logs were found in the event viewer. Despite the documentation mentionning to check there: https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/troubleshoot-event-based-and-spam-reporting-add-ins Is the event viewer the correct places for logs on the new Outlook on desktop ?

neprasad-microsoft commented 2 weeks ago

Hi @navmro Please follow the steps here for new Outlook to collect the logs - https://github.com/OfficeDev/office-js/wiki/Collecting-log-files-for-Outlook-Add%E2%80%90ins-issues You can host it in a private repo and give access to exextoc.

navmro commented 1 week ago

Hi @neprasad-microsoft Thank you, I've collected logs for the new Outlook. Here is the repository only available for exextoc: https://github.com/navmro/outlook-logs

mmanjaree-msft commented 6 days ago

@navmro Could you please confirm if the issue is still reproable. We fixed an issue with the sample addins recently.

navmro commented 6 days ago

@mmanjaree-msft I can see that new Outlook updated. I'm on version 1.2024.501.300 (Production).

The error I get now is :

Error encountered during message processing: The operation is not supported.

From the code at line 24 : https://github.com/OfficeDev/Office-Add-in-samples/blob/main/Samples/outlook-spam-reporting/src/spamreporting.js#L24

It looks like the getAsFileAsync is not working, but I have the registry key set-up:

reg query HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Outlook\Options\WebExt\Developer

  HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Outlook\Options\WebExt\Developer
  EnableBetaAPIsInJavaScript    REG_DWORD    0x1

I've uploaded a new extract from the console + the har on github for exextoc: issue_4411b_operation_not_supported.txt issue_4411b_operation_not_supported.zip

mmanjaree-msft commented 4 days ago

The integrated spam reporting feature is still getting rolled out in outlook web and so it might not be fully available as mentioned in doc https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/spam-reporting#preview-the-integrated-spam-reporting-feature. It is in preview in classic outlook on windows and outlook on mac

navmro commented 4 days ago

The current problem seems to be with the GetAsFileAsync feature, which is supposed to be in preview on the new outlook: https://learn.microsoft.com/en-us/javascript/api/requirement-sets/outlook/preview-requirement-set/outlook-requirement-set-preview?view=common-js-preview#officecontextmailboxitemgetasfileasync

Available in: Outlook on Windows (Microsoft 365 subscription), Outlook on Mac (Microsoft 365 subscription), Outlook on the web (modern), new Outlook on Windows (preview)

I know it's not fully ready yet, that's why I'm testing it and reporting bugs I find.

mmanjaree-msft commented 3 days ago

@navmro Please refresh owa and confirm if its working for you now

navmro commented 3 days ago

@mmanjaree-msft I confirm that it works on owa. I can also confirm that I don't get the error in new outlook anymore.

Thank you very much :)