• Home /
  • Blog /
  • Office Add-in: Dialog API's messageParent not working
Office Add In Dialog Messaging API

Office Add-in: Dialog API's messageParent not working

When building an Outlook plugin, I need a way to communicate between windows. The way Microsoft provides is to use Office messaging API. On your host you need to open a dialog and subscribe to dialog evens the following way:

        height: 60,
        width: 20,
        displayInIframe: false
    }, function (asyncResult) {
        if (asyncResult.status === Office.AsyncResultStatus.Failed) {
                //showNotification(asyncResult.error.code = ": " + asyncResult.error.message);
            } else {
            dialog = asyncResult.value;
            dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
            dialog.addEventHandler(Office.EventType.DialogEventReceived, processDialogEvent);

The following code subscribe host to events which Pop up sends back, for example, "close" event, so your host may close popup

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

Inside of the popup, you can send messages back to host using the following code:

var messageObject = { messageType: "signinSuccess" };
var jsonMessage = JSON.stringify(messageObject);

That all suppose to work, but it does not because of old and misleading documentation and samples provided by Microsoft. When the popup sends message to host, nothing happens, but if you close the popup window, you are going to receive "dialog closed" event.

After some debugging of Office Javascript API, I found that all URLs in the manifest files should have prefix https://. As soon as I have that prefix, it all starts working fine.


Outlook add-in dialog messaging messageParent does not work

Yaplex - Freelance developer - white logo on black background

Yaplex ® is a custom software development company located in Mississauga, Ontario. Yaplex was founded in 2013 and provides website development, mobile development, and custom .NET software development services.

Contact Information

Mississauga, ON, Canada
Phone: +1 647 328 3809
Email: hello@yaplex.com