Working with Contacts on Exchange Server

Getting Contacts with EWS

Aspose.Email provides the EWSClient class to connect to Microsoft Exchange Server using Exchange Web Services. The code snippets that follow use Exchange Web Services to read all the contacts. The following code snippet shows you how to get Contacts with EWS.

Resolve Contacts using Contact Name

The following code snippet shows you how to get contacts using the contact name.

Determining Contact Notes Format

The Contact->get_NotesFormat specifies the contacts' notes text format type defined by TextFormat enumerator.

Fetch Contact using Id

A particular contact can be retrieved from the server using its contact id as shown in the following code sample.

Adding Contacts

The CreateContact() method of the IEWSClient class can be used to add Contact information to an Exchange Server. The CreateContact() method takes a Contact object as an input parameter.

To add contacts to an Exchange Server:

  1. Initialize the IEWSClient with address and credentials.
  2. Initialize the Contact object with the desired properties.
  3. Call the CreateContact() method and pass the contact to add to the Exchange Server.

The following code snippet demonstrates adding contacts to the Exchange Server.

Updating Contacts

Contact information can be updated using Microsoft Outlook. Aspose.Email can also update contact information on Exchange Server using the Exchange Web Service (EWS). The IEWSClient->UpdateContact method can update contact information on Exchange Server.

Deleting Contacts

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

To delete contacts from an Exchange Server:

  1. Initialize the IEWSClient with address and credentials.
  2. Delete a contact using its ID.
  3. Delete a contact by calling the DeleteContact method with Contact as an input parameter.

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