-->

Office.context.mailbox.item.to.getAsync updates TO

2019-06-04 06:53发布

问题:

I start typing in Outlook TO field and at the same moment query every 1s TO field from the installed Add-in.

While I'm still typing I expect to receive an empty array but Outlook (office-js SDK):

  1. Returns data with empty emailAddress and typed displayName
  2. Creates new address with partially typed displayName and incorrect emailAddress generated from typed data.

I can handle the first issue but how to prevent the second one?
Executed code:

Office.cast.item.toItemCompose(Office.context.mailbox.item).to.getAsync(res => {
        if(res.status === Office.AsyncResultStatus.Succeeded) {
                console.log(res.value[0].emailAddress+res.value[0].displayName);
       }
});

Environment:

  • Platform: PC desktop
  • Host: Outlook
  • Office version number: 16
  • Operating System: Windows 10

Issue in Github: https://github.com/OfficeDev/office-js/issues/79

回答1:

@trustifi-trustifi Thanks for reporting this issue.

No. 1 is a known issue that was fixed in build 16.0.8309.1000. If you are still seeing that issue, you are probably on an older version of Outlook, so you will need to upgrade.

For no. 2, I looked at your GitHub post, and you had "test@google.c" as an example of a partially typed display name / incorrect email address. Technically, "test@google.c" is a valid email address, so it can be returned as a recipient once it is resolved by Outlook.

If I have misunderstood your no. 2 question, you have my apologies. Kindly clarify further so that I can provide a better answer.

Overall, instead of polling every 1 second, you need an event that you can subscribe to, so that your add-in is notified when there's a change in recipients. We are currently working on adding more events to our platform to address this issue for developers. Kindly send us a feature request on our UserVoice page.