none
Detecting if Outlook add-in is loaded through outlook.office.com vs outlook.live.com RRS feed

  • Question

  • Hi, 

    Is there a way in the Office.js API to determine if the Outlook add-in we're developing is loaded through outlook.office.com vs outlook.live.com? Office.context.mailbox.diagnostics only returns the hostname and version info, but not the domain its loaded in.

    thanks

    -clfryan

    Monday, May 2, 2016 12:07 AM

Answers

  • Hi clfryan,

    I tested in Office online with Office 365 account both in read and compose mode. I can get the URL as I mentioned like above. Would you mind share more detail how you get URL?

    Here is the code that print the URL for your reference:

       Office.initialize = function (reason) {
            $(document).ready(function () {
                app.initialize();
               
                write(window.location.href);
             
            });
        };
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 4, 2016 8:40 AM
    Moderator

All replies

  • What do you need domain for? (to help me figure out if there is a workaround or other solution for what you are trying to accomplish)

    Monday, May 2, 2016 9:25 PM
  • Our add-in will basically save a url to our app that allows the user to click on a link to reference their email. This url is constructed based on whether the user is on Offfice365 or Outlook.com. We've tried getting the parent URL from the add-in, but some browsers don't allow the Add-in IFrame to access the parent URL unless the iFrame and Parent are using the same domain. 

    Hence, I'm wondering if there is another way to do this, possibly via the Office.js API.

    Monday, May 2, 2016 11:58 PM
  • Hi clfryan,

    The Office.js API doesn't support the detect the detail information for the host at present. As a workaround, we can retrieve these information form the window.location. 

    For example, when I used the Outlook online in Office 365, here are some parameters that the Office online appended after the URL:

    "https://localhost:44300/AppCompose/Home/Home.html?et=&_host_Info=Outlook|Web|16.01#&_xdm_Info=411c18ef_550e14a7_1462266451510|ocii0|https://outlook.office.com/owa/?realm=officedevfei.onmicrosoft.com"

    We can retrieve the "https://outlook.office.com/owa/" from the string above. However, since there no document describe this behavior, it may not be reliable.

    If you want the Office.js API support this feature, you can try to submit the feedback from here.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 3, 2016 9:14 AM
    Moderator
  • Hi Fei,

    I checked the parameters liked you mentioned but the only parameters that were in the URL are 

    et=&_host_Info=Outlook|Web|16.01

    I'm not able to see the param "_xdm_Info" param. Is there some way to enable this?

    Thanks

    -clfryn

    Tuesday, May 3, 2016 5:21 PM
  • It doesn't appear if this is supported directly. Here are some things you can try to see if they work for your situation:

    For Outlook.com vs hosted/on-prem exchange you could figure out the domain from the primary smtp address.

    The ewsURL (dev.outlook.com/reference/add-ins/Office.context.mailbox.html#ewsUrl)

    I believe the ewsURL is currently only available on read items, but support for compose items is in Outlook 2016 C2R version - 16.0.6822.1000 and later. Support for Office 2013 and 2016 MSI versions will be coming soon.

    Check the Tenant ID in the User Identity Token. The tenant ID for consumer users is: "84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa"

    Tuesday, May 3, 2016 11:16 PM
  • Hi clfryan,

    I tested in Office online with Office 365 account both in read and compose mode. I can get the URL as I mentioned like above. Would you mind share more detail how you get URL?

    Here is the code that print the URL for your reference:

       Office.initialize = function (reason) {
            $(document).ready(function () {
                app.initialize();
               
                write(window.location.href);
             
            });
        };
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, May 4, 2016 8:40 AM
    Moderator
  • Thanks Fei! I can definitely work with that and store data into local storage or something.

    For some reason, using "window.location.href" within the actual add-in JS code does not show the params. But it seems to only work within Office.initialize().  

    Much appreciated

    -clfryn

    Wednesday, May 4, 2016 4:58 PM
  • Note that using window.location.href may not work in OnPrem Solutions.

    It does sound like this is a gap in the API. If you think that you still need a solution to this that is supported by the API you should send a request at the UserVoice forums: https://officespdev.uservoice.com/forums/224641-general/category/131778-add-in-outlook

    Monday, May 9, 2016 6:24 PM