1
votes

I have been running into a blocker while developing an O365 Add-in.

Windows Desktop O365 issue: When opening my Add-in for the first time in a compose setting I have access to the Office.context.mailbox.item, however all inline "Reply" and "Reply All"s have my cached Add-in. For this cached Add-in ItemChanged async events do not have access toOffice.context.mailbox.item unless we wait a moment. I.E. Office.context.mailbox.item is undefined.

So in summary the cached Add-in offers a complex issue. ItemChanged shows when a user changes between emails. However what can I do if I have no access to the item?

I thought I would also mention all pop-out "Reply" and "New message" work as anticipated, and all OWA works with the above logic.

Has anyone else faced this issue, or is there a work around of sorts to reestablish the mailbox item once the Add-in in a compose setting has cached?

Code running in my compose Add-in:

export class BaseModule {
       constructor() {}
       
    Office.context.mailbox.addHandlerAsync( Office.EventType.ItemChanged, 
    (eventType) => { console.log(Office.context.mailbox.item.itemId) } 

}
1
Could you share the Outlook build number you are using to test this/seeing this behavior on? Also could you please elaborate the steps to reproduce this issue and what behavior is it that you're seeing that seems broken. - Outlook Add-ins Team - MSFT
Sure @OutlookAdd-insTeam-MSFT, I went ahead and edited some of that description that seemed confusing. My build number is: Version 2012 (Build 13430.20000) To reproduce: 1. Compose a "Reply" (not as a pop out) 2. Request Office.context.mailbox.item (You will receive in the first call) 3. Click "Reply" on a different email 4. Request Office.context.mailbox.item (This will be null) - wsoccorsi
Can you please clarify your scenario a bit more. What do you mean by "cached add-in"? Are you pinning your add-in? - Outlook Add-ins Team - MSFT
Ah yes sorry, once you pin the Add-in it will cache unless the action pops out. - wsoccorsi
Just to clarify your reproduction, Office.context.mailbox.item is only null for a brief moment in your step 4? If so, then the described behavior is consistent with how Outlook Desktop in Windows behaves. Office.context.mailbox.item can be null when you're switching between items, deselected an item or selected an item header. Can you describe what actions you want to take that this issue is preventing you from doing? - Outlook Add-ins Team - MSFT

1 Answers

0
votes
 let timer = setInterval(getOfficeItem, 1000);
 function getOfficeItem {
     if (Office.context.mailbox.item) {
        // Your logic
        clearInterval(timer);
     }
  }

Above is a block of code that I was able to come up with to await the Office item on an ItemChanged event

Update: This seems to have been fixed for replies but not drafts.