Search code examples
outlookoffice-jsoutlook-addinoutlook-web-addins

Outlook JS Add-in - Pass data from taskpane to event


I need help creating an outlook JS Add-in that can forward mails.

The idea
In a taskpane a list of mail addresses is shown that the user can click on.
At the click event the mail should be forwarded to the one the user clicked on.

Current state
The Add-in opens a reply window using Office.context.mailbox.item?.displayReplyAllFormAsync().
With the onNewMessageCompose event I want to change the recipient so that the user only has to click on "Send".
I try to find a work around so that I do not have to use the Graph API.

The issue
How can I pass e. g. the mail address from the taskpane JS code to the onNewMessageComposeHandler e. g. with a "global" storage both have access to?

I already tried using the local storage and the roaming settings. Both did not work.
Update: Thanks to the answer of "Outlook Add-ins Team - MSFT" I found the mistake: When using the roaming storage and you set a value, you have to call saveAsync() afterwards.

According to the offical doc shared runtimes aren't supported:

An Outlook add-in that has the following features has as many as four runtimes. Shared runtimes aren't supported in Outlook.

  • A task pane
  • A function command
  • An event-based task [...]
  • A dialog [...]

Solution

  • You can use Roaming Settings to do this. The roaming setting can be set in your taskpane file and fetched in your LaunchEvent file. Refer this https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/metadata-for-an-outlook-add-in#loading-roaming-settings

    Browser session storage can also be used similarly https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage.