OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
687 stars 94 forks source link

Unable to access Office.context.mailbox.userProfile with Outlook 2016 on Windows 10 and Exchange 2013 server (on-premises) #500

Closed celowsky closed 5 years ago

celowsky commented 5 years ago

I'm working on writing an add-in compatible with Outlook 2016 Windows desktop client (build 16.0.9126.2315 32-bit) connected to Exchange 2013 on-premises from Outlook with requirement set 1.1, but I can't access the Office.context.mailbox.userProfile object.

Expected Behavior

In the Office.initialize function of the add-in, I expect that I can read the value of Office.context.mailbox.userProfile.emailAddress or any other property of the user profile.

Current Behavior

I surround the call to Office.context.mailbox.userProfile.emailAddress inside of a try-catch, and write the error to the document in the catch statement. I receive the following error when trying to read the value:

Unable to get property 'DDA' of undefined or null reference
 at OSF.DDA.OutlookAppOm.prototype._getUserProfile$p$0 (https://appsforoffice.microsoft.com/lib/1.1/hosted/outlook-win32-16.02.debug.js:8804:13)
at Anonymous function (https://ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js:5:298)
at MyAddinFunction (eval code:228:13)
at Office.initialize (eval code:89:9)
at Anonymous function (https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:1645:41)
at validateFunction (https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:278:21)
at LoadScriptHelper.prototype.waitForFunction (https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:290:13)
at appReady (https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js:1641:25)
at OSF.DDA.OutlookAppOm.prototype._callAppReadyCallback$p$0 (https://appsforoffice.microsoft.com/lib/1.1/hosted/outlook-win32-16.02.debug.js:8771:13)
at Anonymous function (https://ajax.aspnetcdn.com/ajax/3.5/MicrosoftAjax.js:5:298) 

Steps to Reproduce, or Live Example

Context

My goal is to get the itemId, an EWS token, and the email address of the desktop client user so that another service can use the EWS token to make a request for the raw MIME content. I need access to the message body completely unaltered.

Your Environment

Useful logs

(function () { 'use strict';

Office.initialize = function (reason) {
    const messageId = Office.context.mailbox.item.itemId; // This is set
    const email = Office.context.mailbox.userProfile.emailAddress; // userProfile is undefined

    document.writeln('Success'); // This line is never printed
};

})();


**manifest.xml**
https://gist.github.com/celowsky/bdc4a8825f4c927618c542cba6d4f8d1
- [ ] Screenshots
- [ ] Test file (if only happens on a particular file)
THPubs commented 5 years ago

@celowsky Did you find a solution for this issue?

shakoorattari commented 3 years ago

Hi, I'm also getting same issue on office for mac 2019

exextoc commented 3 years ago

@shakoorattari could you please provide us more details about the Outlook client. Are you using Outlook New UI or Old UI? Also which version are you using and finally provide us with the code snippet to reproduce the issue?