Werken met contactpersonen op Exchange Server met WebDav
Contents
[
Hide
]
Dit artikel legt uit hoe je contactinformatie direct van een Exchange Server kunt ophalen. Het artikel toont ook hoe je contactpersonen kunt weergeven vanuit de map Contacten.
Contacten ophalen van een Exchange Server
De ExchangeClient klasse’ listContacts() methode kan worden gebruikt om contactinformatie van een Exchange Server op te halen. listContacts() methode vereist de URI van de map Contacten, die eenvoudig verkregen kan worden met de ExchangeMailboxInfo.ContactsUri eigenschap.
Om contactpersonen van een Exchange Server op te halen:
- Initialiseer de ExchangeClient-klasse met adres en inloggegevens.
- Haal de URI van de map Contacten op met de eigenschap ExchangeClient.getMailboxInfo().getContactsUri().
- Roep de listContacts()-methode aan. Deze retourneert een array van MapiContact.
- Voer een foreach-lus uit op de MapiContact-array om de contactinformatie te lezen.
De volgende codefragment toont hoe je de ExchangeClient klasse om alle contactpersonen van een Exchange Server te lezen.
String mailboxURI = "http://ex2003/exchange/administrator"; // WebDAV
String username = "administrator";
String password = "pwd";
String domain = "domain.local";
// Credentials for connecting to Exchange Server
NetworkCredential credential = new NetworkCredential(username, password, domain);
ExchangeClient client = new ExchangeClient(mailboxURI, credential);
// List all the contacts
MapiContact[] contacts = client.listContacts(client.getMailboxInfo().getContactsUri());
for (MapiContact contact : contacts)
{
// Display name and email address
System.out.println("Name: " + contact.getNameInfo().getDisplayName() + ", Email Address: " + contact.getElectronicAddresses().getEmail1());
}