1

尝试使用 IndependentSoft EWS API 从 Exchange 服务器检索联系人时出现以下错误:

The property can not be used with this type of restriction.

这是我的代码:

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;
}
4

1 回答 1

1

像对象的 EWSId 之类的 personaId 是一个标识符,而不是一个验证搜索属性。无论如何,您确实不需要使用它进行搜索,您可以在使用 GetPersona 操作后获得任何信息。如果您确实需要从 Gal 返回 ContactType,如果您尝试从邮箱返回联系人,则需要使用 GetPersona 中的电子邮件地址进行搜索,那么 GetPersona 会将其作为聚合信息的一部分提供给您。

于 2016-11-14T02:18:00.373 回答