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

Dialog on web version of Outlook does not send messages between parent and child


I have an add-in that opens a dialog box using Office.context.ui.displayDialogAsync() with displayInIframe: true

I compose an email and open the add-in. Using the add-in I select the files I wish to attach to the email. On the desktop Outlook app this works perfectly.

On the web version nothing happens. I can't see any communication between the dialog and host page when using Office.context.ui.messageParent() or Office.Dialog.messageChild()

The frontend in the dialog sends a message with the file blob to the parent function in the functionfile. The functionfile should then call addFileAttachmentFromBase64Async() when it receives this message but on the web version I can't see any evidence of this.

I've read it could be to the urls in the in the manifest.xml. Here is ours:

<AppDomains>
    <AppDomain>https://outlook.office.com</AppDomain>
    <AppDomain>https://outlook.live.com</AppDomain>
    <AppDomain>https://localhost:44312</AppDomain>
    <AppDomain>https://*.{company}.cloud</AppDomain>
    <AppDomain>https://localhost:3001</AppDomain>
</AppDomains>

And here is the simplified section of code that opens the dialog:

Office.context.ui.displayDialogAsync(url, { height: 60, width: 60, displayInIframe: true }, asyncResult => {
        if (handleError(asyncResult)) return;

        dialog = asyncResult.value;

        dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);

        const promises = [];

        {working business logic}

        Promise.all(promises).then(values => {
            {working business logic}

            event.completed();
        });
    });

Other issues we have in the web version that might be releavent:

  • The 'X' close button in the top right of the dialog box does not work. Neither will calls to Office.context.ui.closeContainer() or Office.Dialog.close()
  • If we set displayInIframe: false then the add-in will immediately close itself upon opening unless we throttle our internet connect. But even when throttling the attaching email process does not work. If I remove the <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js" crossorigin></script> script in the .html then it no longer crashes (but naturally the app needs that)

I have tested this on both Edge and Chrome and they both have this issue. I have not tested on any other browsers

Again, the app works correctly and as expected on the Outlook desktop app. Any help or suggests are appreciated. Thanks.


Solution

  • Just remove the event.completed() call from the callback.