Brett McKenzie
Brett McKenzie

Reputation: 605

Office.context.mailbox.diagnostics.hostName returns incorrect value for Outlook on a Mac

When using OfficeJS to determine what office client is being used, I am calling Office.context.mailbox.diagnostics.hostName but am given Outlook for users on Outlook for Mac when I expect to get Mac Outlook

According to https://github.com/OfficeDev/office-js-docs/blob/master/reference/outlook/Office.context.mailbox.diagnostics.md, the possible values for the hostname can be Outlook, Mac Outlook, OutlookIOS, or OutlookWebApp

I am using the latest OfficeJs from https://appsforoffice.microsoft.com/lib/1/hosted/office.js

Upvotes: 2

Views: 715

Answers (3)

sonmt
sonmt

Reputation: 66

Currently, you can use Browser UserAngent to detect add-in is running on Outlook App for Mac.

Office.initialize = function () {
    //if Add-in is opening in Outlook App for MAC.
    var OutlookHost = Office.context.mailbox.diagnostics.hostName;
    var platform = navigator.platform;
    if (OutlookHost !== null && OutlookHost !== undefined && OutlookHost === "Outlook" && platform != null && platform.toLowerCase().indexOf("mac") >= 0) {
        return true;
    }
 }

navigator.platform will return:

"MacIntel"

Upvotes: 0

Brett McKenzie
Brett McKenzie

Reputation: 605

The documentation has been changed to remove any mention of Mac Outlook. It now suggests that the output will be Outlook when on a Mac client.

Upvotes: 0

Shweta Dhawan
Shweta Dhawan

Reputation: 13

We are working to fix this issue. Meanwhile, as a workaround you can use useragent in your add in to identify the browser. We will let you know as soon as this issue is fixed.

Upvotes: 0

Related Questions