Hi everyone,
I can get all contacts from Your Contacts folder successfully.
How can I get all contacts in that Directory folder from EWS?
I tried this code but it throws error:
Exception: The distinguished folder name is unrecognized.
ews.EwsLogging.DebugLogEnabled = false;
let exch = new ews.ExchangeService(ews.ExchangeVersion.Exchange2013);
exch.Credentials = new ews.ExchangeCredentials("username", "password");
exch.Url = new ews.Uri("https://outlook.office365.com/Ews/Exchange.asmx");
exch.FindItems(
[
new ews.FolderId(ews.WellKnownFolderName.Directory) // Changed .Contacts to .Directory
],
null,
null,
new ews.ItemView(10),
null,
ews.ServiceErrorHandling.ReturnErrors
).then(function (resp) {
resp.Responses[0].Results.Items.forEach(function (item) {
console.log(item.EmailAddresses.Entries.Values);
});
}, function (ei) {
console.log(ei.stack, ei.stack.split("\n"));
});
You want to use ResolveName
method on ExchangeService
instance rather than using a folder type. the Directory information is coming from Global Address List in Exchange Populated from Active Directory
https://msdn.microsoft.com/en-us/library/office/jj190895(v=exchg.150).aspx