Free Support Forum - aspose.com

Exchange: Find a Contact By Name

Hi,

How can we find a contact on Exchange server using its name?

Hi Aaron,


Thank you for posting your inquiry.

The EWSClient.ResolveContact can help you find a contact from Exchange Contacts. Please try the following sample code and share your feedback with us if you need further assistance.

Code:

// Create instance of IEWSClient class by giving credentials
IEWSClient client = EWSClient.GetEWSClient(“https://outlook.office365.com/ews/exchange.asmx, “testUser”, “pwd”, “domain”);

// List all the contacts
Contact[] contacts = client.ResolveContacts(“Contact Name”, ExchangeListContactsOptions.FetchAttachmentAndFullPhotoInformation);
// Loop through all contacts
foreach (MapiContact contact in contacts)
{
// Display name and email address
Console.WriteLine("Name: " + contact.NameInfo.DisplayName +
", Email Address: " + contact.ElectronicAddresses.Email1);
}