Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Office.context.mailbox.item does not update without the ItemChanged listener #5340

Open
CodeCube0 opened this issue Jan 31, 2025 · 3 comments
Labels
Area: Outlook Issue related to Outlook add-ins Possible-Solution Similar-Issue Type: product feature request Office JS ideas that should be posted to aka.ms/m365dev-suggestions (formerly User Voice.)

Comments

@CodeCube0
Copy link

Description:

I'm experiencing an issue with the Office JavaScript API for Outlook. When switching emails within the task pane, the Office.context.mailbox.item object does not update automatically.

Steps to Reproduce:

Open the task pane of an Outlook add-in.
Retrieve the value of Office.context.mailbox.item.
Switch to a different email in the Outlook client.
Retrieve Office.context.mailbox.item again without reloading the add-in.

Expected Behavior:

The Office.context.mailbox.item object should automatically update when switching emails.

Actual Behavior:

The item value remains unchanged, still showing the data from the previous email.

Current Workaround:

The issue can be resolved by adding a listener for the Office.EventType.ItemChanged event and retrieving Office.context.mailbox.item inside the event callback.

Office.context.mailbox.addHandlerAsync( Office.EventType.ItemChanged, () => { console.log("Item updated:", Office.context.mailbox.item); } );

Additional Notes:

It would be helpful if Office.context.mailbox.item updated automatically without requiring an explicit event listener.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP label Jan 31, 2025
Copy link

Here are some similar issues that might help you. Please check if they can solve your problem.


Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Ensure that your add-in is using WebView2 instead of Edge HTML. You can do this by adding the registry key HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\WEF\Win32WebView2 and setting its value to dword:00000001. This workaround has been reported to work for users on the Semi-Annual Enterprise channel and Current channel.

Reference:

@exextoc exextoc added Area: Outlook Issue related to Outlook add-ins Needs: attention 👋 Waiting on Microsoft to provide feedback and removed Needs: triage 🔍 New issue, needs PM on rotation to triage ASAP labels Jan 31, 2025
@neprasad-microsoft
Copy link

Hi @CodeCube0
Currently the feature of changing itemId without listening to the itemChanged event, is not a part of the product. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered, when we go through our planning process.

@neprasad-microsoft neprasad-microsoft added Type: product feature request Office JS ideas that should be posted to aka.ms/m365dev-suggestions (formerly User Voice.) and removed Needs: attention 👋 Waiting on Microsoft to provide feedback labels Jan 31, 2025
@CodeCube0
Copy link
Author

Hi @CodeCube0
Currently the feature of changing itemId without listening to the itemChanged event, is not a part of the product. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered, when we go through our planning process.

Thank you for your reply. The issue is not related to the itemId, but rather to Office.context.mailbox.item itself, which doesn't update as expected when the item changes.

Could you please clarify if there's a recommended approach to handle this scenario?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Outlook Issue related to Outlook add-ins Possible-Solution Similar-Issue Type: product feature request Office JS ideas that should be posted to aka.ms/m365dev-suggestions (formerly User Voice.)
Projects
None yet
Development

No branches or pull requests

3 participants