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
648 stars 92 forks source link

Cannot fetch the account emailAddress from outlook desktop on an exchange account #790

Closed THPubs closed 3 years ago

THPubs commented 4 years ago

Expected Behavior

Office.context.mailbox.userProfile.emailAddress to return the email of the user's account inside an Outlook Addin.

Current Behavior

It is returning the email as a string in all occasions except when I use the Outlook mac client and with an email account hosted in an Exchange server (2016 CU 12). In this particular case, it does not return the email.

Steps to Reproduce, or Live Example

Your Environment

exextoc commented 4 years ago

Thanks for reporting this issue. What does it return with Exchange server 2016 CU 12? Does the API fail or returns "empty" or "null"?

THPubs commented 4 years ago

Looks like it returned undefined.

exextoc commented 4 years ago

Thanks for quick response. Is this problem happening in "Mac Outlook" only or with "Windows Outlook" as well?

THPubs commented 4 years ago

Your welcome! I did not try Windows yet. But it does happen in both Mac Desktop and on the web version (Firefox).

THPubs commented 4 years ago

Wait. Really sorry. It does work on the Web version. The only problem is with the desktop version. But didn't test on Windows and Mobile yet.

exextoc commented 4 years ago

Thank you for reporting this issue. It has been put on our backlog. We unfortunately have no timelines to share at this point.

mashuangnong commented 4 years ago

Same problem occurs on my mac pro. The version of outlook is 16.16.11, 16.16.3; I need somebody help, Is there another way to get emialAddress by office.js in outlook ?

exextoc commented 4 years ago

User email address is exposed only via Office.context.mailbox.userProfile.emailAddress and there is no other way to access it. Can you try to update your outlook version and check if it helps.

AnjanaValsan commented 4 years ago

@mashuangnong Can you share the following details? 1) Version of exchange if its an exchance on-prem account 2) Office license details 3) does any of the APIs under Office.context.mailbox.userProfile work for you? (like displayName,timezone)? 4) MacOS details 5) Is there a test account that we can try to repro this issue?

mashuangnong commented 4 years ago

@AnjanaValsan Thanks. here are details we get:

  1. Outlook version version: 16.16.11(190609) image
  2. macOS: Mojave version: 10.14.6 image
  3. Our outlook add-in only uses the emailAddress under Office.context.mailbox.userProfile.
  4. Sorry, there is no test account due to the security;
exextoc commented 4 years ago

Hey @mashuangnong ,

We are unfortunately still unable to reproduce this issue due to the lack of a test account where this issue exists. Could you please tell us whether your account is on exchange online or On-prem or on gmail?

exextoc commented 4 years ago

Hi @mashuangnong , we have tried testing this issue on the same Exchange version as yours (2016 CU 12) and we're still unable to reproduce this. The only way we can fix this seems to be for us to get hold of a test account. Is it possible?

ghost commented 4 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

mashuangnong commented 4 years ago

I'm terribly sorry,and I am busy doing something else; Thanks a lot for following the issue. We develop an add-in for company, and the emailAddress is used as id for employee. It works for some people, but it also don't work for several people. Those computer were purchased between 2015 and 2016, and does it matter ? We have added some tips and links to help people finish on web. Thanks again.

ghost commented 4 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

ghost commented 4 years ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.

westconference commented 3 years ago

I also see this issue where userProfile.emailAddress is undefined with the following environment;

Issue does not occur for me on Windows Outlook clients (2016 and 365 check).

exextoc commented 3 years ago

@westconference Is this issue consistently occurring for all users in the specified environment? Could you please share a test account with which this issue can be reproduced?

westconference commented 3 years ago

@exextoc It's consistent yes for all users. I can't share a test account as it's an on-premise lab Exchange Server not exposed externally.

exextoc commented 3 years ago

@westconference Does any of the APIs under Office.context.mailbox.userProfile work for you? (like displayName,timezone, accountType)?

westconference commented 3 years ago

@exextoc displayName, timezone and accountType are also undefined on Mac Outlook against Exchange 2016. They are all set in OWA

Full JSON stringify output for userProfile on Mac Outlook is below (with actual values swapped out for 'test' etc);

{
   "_data$p$0":{
      "_data$p$0":{
         "attachments":[
            {
               "id":"AAMkADBmZjg4ODljLTMyNDUtNDM1OC05MDQwLTg3NDQ4NzJmYmEzMwBGAAAAAACJFDkNMMXaR6TgvmhG+xIBBwBDny06OEEPS6HObxmDj7YCAAAAAAEMAABDny06OEEPS6HObxmDj7YCAAFE1TicAAABEgAQAOzwc60jnlBJiAF/1WbeyK0=",
               "name":"ttest subject.eml",
               "contentType":"message/rfc822",
               "size":2346,
               "attachmentType":1,
               "isInline":false
            }
         ],
         "cc":null,
         "conversationId":"AAQkADBmZjg4ODljLTMyNDUtNDM1OC05MDQwLTg3NDQ4NzJmYmEzMwAQAGukja4PxBRJhh1+2gtdrF8=",
         "dateTimeCreated":1595321731000,
         "dateTimeModified":1595321731000,
         "dateTimeSent":1595321730000,
         "entities":{
            "Addresses":null,
            "Contacts":null,
            "EmailAddresses":[
               "test2@test.test.com"
            ],
            "MeetingSuggestions":null,
            "PhoneNumbers":null,
            "TaskSuggestions":null,
            "Urls":null
         },
         "ewsUrl":"https://test.2016.com/EWS/Exchange.asmx",
         "filteredEntities":null,
         "from":{
            "address":"test2@test.test.com",
            "name":"test2 add-in",
            "recipientType":2,
            "appointmentResponse":0
         },
         "hostVersion":"16.39 (20071300)",
         "id":"AAMkADBmZjg4ODljLTMyNDUtNDM1OC05MDQwLTg3NDQ4NzJmYmEzMwBGAAAAAACJFDkNMMXaR6TgvmhG+xIBBwBDny06OEEPS6HObxmDj7YCAAAAAAEMAABDny06OEEPS6HObxmDj7YCAAFE1TicAAA=",
         "internetMessageId":"d9e6aaf5b714431b9ee65c5f216d8b9c@test.test.com",
         "itemClass":"IPM.Note",
         "itemType":1,
         "location":"",
         "normalizedSubject":"test subject",
         "permissionLevel":2,
         "restUrl":"",
         "selectedEntities":{
            "Addresses":null,
            "Contacts":null,
            "EmailAddresses":null,
            "MeetingSuggestions":null,
            "PhoneNumbers":null,
            "TaskSuggestions":null,
            "Urls":null
         },
         "sender":{
            "address":"test2@test.test.com",
            "name":"test2 add-in",
            "recipientType":2,
            "appointmentResponse":0
         },
         "seriesId":null,
         "subject":"test subject",
         "to":[
            {
               "address":"test@test.test.com",
               "name":"test add-in",
               "recipientType":2,
               "appointmentResponse":0
            }
         ],
         "userTimeZone":"Greenwich Mean Time",
         "wasSuccessful":1,
         "error":false
      },
      "_permissionLevel$p$0":3
   }
}

Note the Exchange server does have a restUrl defined on other platforms even though it is empty here and the getCallbackTokenAsync call succeeds in returning V2 Exchange Callback token on Mac Outlook.

exextoc commented 3 years ago

Thanks for sharing this information. We are not able to repro this on our side. However, we are working on another fix which could potentially fix this issue as well. Once fix is deployed, we will reach out to you to confirm if the issue persists or not.

exextoc commented 3 years ago

We would like to have a look at the network trace for an Account that is facing this issue. Can you share the same to MeganB@M365B998009.OnMicrosoft.com ?

ghost commented 3 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

ghost commented 3 years ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.

andmaz commented 3 years ago

I have the same issue, here are some investigation details: 1) It's not stable and occurs rarely, mostly on MasOS (owa/desktop), but on Windows (desktop) as well. 2) All properties from userProfile (accountType, displayName, emailAddress, timeZone) are undefined 3) All properties are available in Office.context.mailbox.initialData (userProfileType, userDisplayName, userEmailAddress, userTimeZone) 4) It seems like it's not only related to Exchange, but to office365 as well

Hope that helps

exextoc commented 3 years ago

@andmaz Thanks for sharing this information. We are not able to repro this on our side.Could you please share a test account with which this issue can be reproduced?

ghost commented 3 years ago

This issue has been automatically marked as stale because it is marked as needing author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your interest in Office Add-ins!

ghost commented 3 years ago

This issue has been closed due to inactivity. Please comment if you still need assistance and we'll re-open the issue.

GrumpyAL commented 3 years ago

I know this is an older closed ticket but I ran into this today and wanted to share some information in case it helps with repro steps or others run into this. I was working in an environment that was (or had) migrating from on-prem Exchange to 365 and running into this issue where Office.context.mailbox.userProfile.emailAddress returned undefined. This was on Outlook for Mac 16.46. The mailbox being tested was fully 365 to my knowledge.

It turned out, that the profile setup up in Preferences->Accounts was missing the Full Name value. Once we filled in the user's Full Name, restarted Outlook and tried again we were able to pull the emailAddress property. I did not check to see if other properties of the userProfile interface were available prior to this fixing it. We could not reverse the test because the client would not let us clear the Full Name property (it just added it again). I'm not sure if this is related to the original report since it was only Outlook for Mac that was impacted.

ndvbd commented 3 years ago

I think I solved the problem by wrapping the call with:

Office.onReady(function(info) {

westconference commented 3 years ago

I know this is an older closed ticket but I ran into this today and wanted to share some information in case it helps with repro steps or others run into this. I was working in an environment that was (or had) migrating from on-prem Exchange to 365 and running into this issue where Office.context.mailbox.userProfile.emailAddress returned undefined. This was on Outlook for Mac 16.46. The mailbox being tested was fully 365 to my knowledge.

It turned out, that the profile setup up in Preferences->Accounts was missing the Full Name value. Once we filled in the user's Full Name, restarted Outlook and tried again we were able to pull the emailAddress property. I did not check to see if other properties of the userProfile interface were available prior to this fixing it. We could not reverse the test because the client would not let us clear the Full Name property (it just added it again). I'm not sure if this is related to the original report since it was only Outlook for Mac that was impacted.

This worked for an O365 user who was seeing this with our add-in. Full Name hadn't been set, entered a value and restarted then add-in was able to get the user email address. Thanks @GrumpyAL.

shakoorattari commented 2 years ago

Issue is still there for office for mac 2019

exextoc commented 2 years ago

@shakoorattari are you using the new UI or old UI?

shakoorattari commented 2 years ago

@exextoc what are new and old UIs?

shakoorattari commented 2 years ago

@GrumpyAL saved the life. It's working after adding the full name.

andmaz commented 1 year ago

I have the same issue, here are some investigation details:

  1. It's not stable and occurs rarely, mostly on MasOS (owa/desktop), but on Windows (desktop) as well.
  2. All properties from userProfile (accountType, displayName, emailAddress, timeZone) are undefined
  3. All properties are available in Office.context.mailbox.initialData (userProfileType, userDisplayName, userEmailAddress, userTimeZone)
  4. It seems like it's not only related to Exchange, but to office365 as well

Hope that helps

By the way, this issue still occurs from time to time. It's really unstable (occurred twice last month on the test environment), so I cannot share the test account.

I can try to grab some details from the dev tools if it may help. Currently, we know that:

Thanks