Search code examples
reactjsoutlook-addinoffice-addinsoutlook-web-addins

Trigger event on selection mail item or change selection of mail item


I am trying to create a outlook plugin in React JS to detect mail selected or mail selection change.

Tried Mailbox EvenetType ItemChanged, add handler for event is return success but handler not called when user select or change selected mail from list.

The code I used is as below

Office.onReady(() => {
  // If needed, Office.js is ready to be called
  Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, 
    (eventType) => mailItemChanged(eventType), 
    (AsyncResult) => {console.log(AsyncResult)});
});

function mailItemChanged(eventType) {
  console.log('Office.EventType.ItemChanged triggered');
}

Please let me if there is any other option to trigger email selection change event


Solution

  • This event was introduced to update the pane when selection is changed. The web add-ins work under the context of item selected in Outlook. So, it is expected to get the event triggered when the task pane is pinned.