Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Office.EventType.ItemChanged doesn't seem to fire

I am trying to test a simple console.log print test when I move from one email to another in outlook. I am following the instructions from Microsoft here: https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/pinnable-taskpane#handling-ui-updates-based-on-currently-selected-message

My manifest file already supports pinning and I use pinning in all my outlook addin projects.

I followed this code from microsoft yet it doesn't seem to do anything in the developer console:

function itemChanged(eventArgs) {
  // Update UI based on the new current item
  UpdateTaskPaneUI(Office.context.mailbox.item);
}

// Example 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);
  });
};

I was assuming that I was going to receive the subject of which ever email I was highlighted on in outlook but nothing happened. I also double clicked on an email to see if the event was fired only by the email being in its own window and nothing happened still.

I am running Microsoft® Outlook® for Microsoft 365 MSO (Version 2111 Build 16.0.14701.20254) 64-bit

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I was able to get it to work. I was first testing in the dev tool's console so I assumed that would have worked but it was casuing me errors. The moment I tested the code in the javascript for the outlook addin itself it started to work:

Office.onReady((info) => {
  $(document).ready(function () {

    function itemChanged(eventArgs) {
      // Update UI based on the new current item
      UpdateTaskPaneUI(Office.context.mailbox.item);
    }
    
    // Example implementation
    function UpdateTaskPaneUI(item)
    {
      // Assuming that item is always a read item (instead of a compose item).
      if (item != null) console.log(item.subject);
    }
  
        // Set up ItemChanged event
        Office.context.mailbox.addHandlerAsync(Office.EventType.ItemChanged, itemChanged);
    
        UpdateTaskPaneUI(Office.context.mailbox.item);
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!