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

Is there a way to modify an email address in Outlook using the Office Javascript API?


I am looking for a way to automatically change an email address or be able to add a CC based on a condition. Is there an OfficeJS API call for outlook that lets me "edit" an email address or is able to add a CC based on a button click?


Solution

  • In Compose Mode recipients can be accessed via Office.context.mailbox.item.to or cc. There are both getAsync() and setAsync() functions on those.

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

    You can also subscribe to the RecipientsChangeEvent to find out when a user has changed it.

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

    Recipients can be accessed but not changed in Read Mode