Search code examples
outlookoffice-jsoutlook-addinoffice-addinsoutlook-web-addins

Office JS AddIn Question - Detecting Attendee Change


I'm working on an Office JS add-in that requires detecting when creating a new appointment/meeting in Office 365 Outlook to call some function. I ran into the following on Microsoft's site:

https://learn.microsoft.com/en-us/javascript/api/outlook/office.recipientschangedfields?view=outlook-js-1.11

I tried using:
Office.context.mailbox.addHandlerAsync(Office.RecipientsChangedFields, function(){ ... }

But that doesn't seem to be correct, anyone have any idea?


Solution

  • You need to set up the event handler on the item object, not mailbox:

    Office.context.mailbox.item.addHandlerAsync(
                Office.EventType.RecipientsChanged,
                () => {
                  console.log("Recipients changed");
                },
                (asyncResult) => {
                  if (asyncResult.status === Office.AsyncResultStatus.Failed) {
                    console.error(asyncResult.error);
                    reject();
                  } else {
                    resolve();
                  }
                }
              );