I was experiencing the same issue. Thought to re-register the event handler and it worked.
Here is the code I am using.
Office.onReady(function() {
//console.log('In Office.onReady');
if(!Office.context.mailbox) {
console.log('Run inside Outlook to be able to use it.');
return;
}
console.log('Running in Office Add-in');
// Set up ItemChanged event
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, selectedMailItemChanged);
console.log('Item Change event registered.');
doSomething(Office.context.mailbox.item);
//console.log('Page initialized');
});
function selectedMailItemChanged(eventArgs) {
console.log('Another email message selected');
if(Office.context.mailbox.item != null) {
doSomething(Office.context.mailbox.item);
}
else {
console.log('No email is selected.');
Office.context.mailbox.removeHandlerAsync(Office.EventType.ItemChanged, {handler: selectedMailItemChanged}, function(result) {
console.log('Item Change event unregistered.');
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, selectedMailItemChanged);
console.log('Item Change event re-registered.');
});
}
}
function doSomething(item) {
// do something.
}
However, in another case where you can navigate to another web-page from within your add-in, while the add-in was still open, see this answer.