尝试使用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;
}
像对象的EWSId一样的personaId是标识符,不是有效的搜索属性。使用GetPersona操作之后,您确实确实不需要搜索它,您可以获得任何信息。如果您确实需要从Gal中返回ContactType,并且如果您尝试从邮箱中返回联系人,则需要使用GetPersona的电子邮件地址进行搜索,然后GetPersona会为您提供该信息作为汇总信息的一部分。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句