Skip to content

Instantly share code, notes, and snippets.

@davecra
Created March 4, 2020 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davecra/2d14d48fd75f11b65053e7b75378e3e6 to your computer and use it in GitHub Desktop.
Save davecra/2d14d48fd75f11b65053e7b75378e3e6 to your computer and use it in GitHub Desktop.
EasyEws resolveRecipient sample
async function run() {
var msg = Office.context.mailbox.item;
msg.to.getAsync(function(asyncResult) {
if(asyncResult.status == Office.AsyncResultStatus.Failed) {
$("#recipientResult").text(asyncResult.error);
} else {
/** @type {Office.EmailAddressDetails[]} */
var recips = asyncResult.value;
// are there any recipients at all
if(recips == null || recips.length == 0) {
$("#recipientResult").html("NO RECIPIENTS");
} else {
/** @type {string} */
var info = "<br/>DISPLAY NAME: " + recips[0].displayName + "<br/>" +
"EMAIL_ADDRESS: " + recips[0].emailAddress + "<br/>" +
"RECIPIENT_TYPE: " + recips[0].recipientType;
easyEws.resolveRecipient(recips[0].emailAddress, function(result) {
if(result == null || result.length == 0) {
info += "<br/>UNRESOLVED</br>";
} else {
info += "<br/>RESOLVED: " + result[0].MailBoxType;
info += "<br/>RESOLVED EMAIL: " + result[0].EmailAddress;
}
// write tot he form
$("#recipientResult").html(info);
}, function(error) {
$("#recipientResult").text(error);
}, function(debug) {
$("#debugResult").text(debug)
});
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment