Java EWS - ResolveName not retrieving all email ids from Outlook
I am trying to retrieve list of users from Outlook using the Outlook API Exchange Webservices in a java stand alone application. To retrieve the list, I am using "resolveName". I find that sometimes when outlook returns multiple email ids for a name, the list that resolveName returns does not contain the last address. This does not happen with all the names that have multiple email ids returned by outlook. Example - if the name "John Test" returns 5 emails ids when manually searched for in Outlook, the method resolveName returns only 4 addresses. Does anybody have an idea of what might be happening here, or if I should use some method other than resolveName?
I'm a bit confused about Outlook API. Could you show piece of code and raw EWS request and response for ResolveName request?
The code that I use is this -
ExchangeService exchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP2); ExchangeCredentials credentials = new WebCredentials(username, password, domain); exchangeService.setCredentials(credentials); exchangeService.setUrl(URI.create("url to exchange")); NameResolutionCollection nameResults = exchangeService.resolveName("FirstName,LastName"); for (NameResolution name : nameResults) { emailAddr = name.getMailbox().getAddress(); }
When I manually lookup "FirstName,LastName" in outlook, I get 5 matching email addresses. But the above code snippet returns only 4 email addresses.
It's quite interesting. Do you see any differences between contacts (contact that isn't found and contacts that are found)?