Manage Contacts with Exchange Web Services (EWS)

Aspose.Email lets you work with more than just email messages on Microsoft Exchange Server. Using the EWSClient API, you can retrieve, resolve, create, update, and delete contacts stored in an Exchange mailbox. This article explains the key operations for managing contacts with Exchange Web Services (EWS).

Get Contacts with EWS

Aspose.Email provides the EWSClient class to connect to Microsoft Exchange via EWS. The example below shows how to read all contacts from the Contacts folder:

Resolve Contacts by Name

You can resolve contacts using a display name. The following example fetches matching contacts and their details:

Determine Contact Notes Format

The Contact->get_NotesFormat property specifies the format of the notes text according to the TextFormat enumerator.

Fetch Contact using Id

You can retrieve a specific contact using its unique contact ID as shown in the code sample below.

Add Contacts

Use the CreateContact() method to add a new contact to Exchange Server. The following example demonstrates how to populate and save a contact:

Update Contacts

Contact information can be modified on the server using IEWSClient->UpdateContact. The following code sample demonstrates how to retrieve, display, and update Exchange Server contacts:

Deleting Contacts

The IEWSClient class provides the DeleteContact to access and delete contacts from the Exchange Server. This method takes the contact ID or Contact as an input parameter.

The following code snippet shows you how to delete contacts from an exchange server using IEWSClient->DeleteContact.