I am getting the following error when trying to retrieve a contact from Exchange server using IndependentSoft EWS API:
The property can not be used with this type of restriction.
Here is my code:
public Contact GetContact(string id){
var restriction = new IsEqualTo(PersonaPropertyPath.PersonaId, id);
var persona = _service.FindPeople(StandardFolder.Contacts, restriction).Personas.FirstOrDefault();
if (persona == null)
throw new NullReferenceException("Could not find contact in Exchange");
var contact = new Contact
{
Id = persona.PersonaId.ToString(),
Name = persona.DisplayName
};
if (persona.EmailAddress != null)
{
contact.Email = persona.EmailAddress.EmailAddress;
}
return contact;
}
The personaId like the EWSId of an Object is an identifier and isn't a validate search property. You really shouldn't need to search with it anyway you can get any information you after using the GetPersona Operation. If you really need to return the ContactType from the Gal you will need to search using the Email address from GetPersona if you trying to return a Contact from a Mailbox then GetPersona will give you that as part of the aggregate information.