Reputation: 357
I need to get the email address corresponding to a particular Username in outlook through JAVA. I have tried digging into the microsoft exchange webservices API, but couldnt find anything useful. The only faint hope i had was with the , resolveNames() method, but that proved to be a dead end. Does anyone have an idea on how to go about it?
what i basically need is this :
username : "abcxqz"
when we do a Ctrl + k on outlook, it gives the corresponding contact or email address.
i need to simulate the same functionality in code( JAVA ) . Any pointers or links to API's that could help me achieve this would be greatly appreciated. Cheers
Upvotes: 1
Views: 4134
Reputation: 357
public void getEmailId() throws Exception {
init();
NameResolutionCollection nameResults = exchangeService.resolveName("royran");
Map<String, String> results = new TreeMap<String, String>();
for (NameResolution name : nameResults) {
String contactName = name.getMailbox().getName();
String emailAddress = name.getMailbox().getAddress();
results.put(contactName, emailAddress);
}
for (Map.Entry<String, String> entry : results.entrySet())
{
System.out.println(entry.getKey() + "/" + entry.getValue());
}
}
}
Upvotes: 0
Reputation: 49395
What code exactly do you use? Could you be more specific?
You can use the ExchangeService.ResolveName EWS Managed API method or the ResolveNames EWS operation to return a list of potential matches for a selection of text, such as part of a last name. The returned items can be public user mailboxes, distribution groups, and contacts.
// Resolve the ambiguous name "dan".
NameResolutionCollection resolvedNames = service.ResolveName("dan");
// Output the list of candidates.
foreach (NameResolution nameRes in resolvedNames)
{
Console.WriteLine("Contact name: " + nameRes.Mailbox.Name);
Console.WriteLine("Contact e-mail address: " + nameRes.Mailbox.Address);
Console.WriteLine("Mailbox type: " + nameRes.Mailbox.MailboxType);
}
See How to: Resolve ambiguous names by using EWS in Exchange 2013 for more information.
Upvotes: 1