We use the OfficeJs REST API for add-in development.
To use this API, an accesstoken is needed, which we request by invoking Office.mailbox.getCallbackTokenAsync({ isRest: true })
during startup of our add-in.
This does not fail for any code triggered by the onSend function: It seems OfficeJs saves the mail item before onSend code is triggered.
However, this request apparently does fail when the mail item is not yet saved - which is the case for any new draft when it is just created - and thus breaks the init code of our add-in when the task pane is opened straight after composing a new message.
To remedy that, one can call Office.messageCompose.saveAsync
.
This however causes the task pane to disappear as the current mail item is refreshed (hypothesis).
Is there anything that we can do to prevent the task pane from being closed after calling saveAsync
or retrieve the REST access token without having to save the mail item first ?
To avoid the issue of the Task Pane closing, please use the new version of Outlook Web. The bug has been fixed in this version of Outlook.