Currently, I am exploring a simple console.log print test to see how it behaves when I switch from one email to another within Outlook. To guide me through this process, I have been referring to the instructions provided by Microsoft over at this link.
In all my Outlook add-in projects, I already incorporate pinning features in my manifest file.
Following the code example given by Microsoft, it appears that the expected behavior does not occur as intended in the developer console:
function itemChanged(eventArgs) {
// Update UI based on the new current item
UpdateTaskPaneUI(Office.context.mailbox.item);
}
// Sample implementation
function UpdateTaskPaneUI(item)
{
// Assuming that item is always a read item (instead of a compose item).
if (item != null) console.log(item.subject);
}
Office.initialize = function (reason) {
$(document).ready(function () {
// Set up ItemChanged event
Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, itemChanged);
UpdateTaskPaneUI(Office.context.mailbox.item);
});
};
My expectation was to retrieve the subject of the highlighted email in Outlook, yet nothing seemed to happen. Even after double-clicking on an email to open it in its own window, the event failed to trigger any response.
The version of Microsoft® Outlook® running on my system is Microsoft 365 MSO (Version 2111 Build 16.0.14701.20254) 64-bit.