WebDav를 사용하여 Exchange Server에서 연락처 작업하기
Contents
[
Hide
]
이 문서는 Exchange Server에서 직접 연락처 정보를 검색하는 방법을 설명합니다. 또한 연락처 폴더에서 연락처를 나열하는 방법을 보여줍니다.
Exchange Server에서 연락처 가져오기
다음은 ExchangeClient 클래스 listContacts() 메서드는 Exchange Server에서 연락처 정보를 가져오는 데 사용할 수 있습니다. listContacts() 메서드는 연락처 폴더의 URI가 필요하며, 이는 다음을 사용하면 쉽게 얻을 수 있습니다. ExchangeMailboxInfo.ContactsUri 속성.
Exchange Server에서 연락처를 가져오려면:
- 주소와 자격 증명을 사용하여 ExchangeClient 클래스를 초기화합니다.
- ExchangeClient.getMailboxInfo().getContactsUri() 속성을 사용하여 연락처 폴더의 URI를 가져옵니다.
- listContacts() 메서드를 호출하십시오. MapiContact 배열을 반환합니다.
- MapiContact 배열에 대해 foreach 루프를 수행하여 연락처 정보를 읽습니다.
다음 코드 스니펫은 다음을 사용하는 방법을 보여줍니다. ExchangeClient Exchange Server에서 모든 연락처를 읽기 위한 클래스.
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());
}