2014-11-21 47 views
0

我想通过EmailAddress搜索联系人。使用下面的代码通过EmailAddress搜索联系人EWS

<m:FindItem Traversal="Shallow"> 
    <m:ItemShape> 
    <t:BaseShape>AllProperties</t:BaseShape> 
    <t:AdditionalProperties> 
     <t:FieldURI FieldURI="contacts:DisplayName" /> 
    </t:AdditionalProperties> 
    </m:ItemShape> 
    <m:Restriction> 
    <t:Or> 

    <t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase"> 
     <t:IndexedFieldURI FieldURI="contacts:EmailAddress" FieldIndex="EmailAddress1" /> 
     <t:Constant Value="test" /> 
    </t:Contains> 

    <t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase"> 
     <t:IndexedFieldURI FieldURI="contacts:EmailAddress" FieldIndex="EmailAddress2" /> 
     <t:Constant Value="test" /> 
    </t:Contains> 

    <t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase"> 
     <t:IndexedFieldURI FieldURI="contacts:EmailAddress" FieldIndex="EmailAddress3" /> 
     <t:Constant Value="test" /> 
    </t:Contains> 
    </t:Or> 

</m:Restriction> 
    <m:ParentFolderIds> 
    <t:DistinguishedFolderId Id="contacts" /> 
    </m:ParentFolderIds> 
</m:FindItem> 

它对一些联系人工作正常。但是,我应该怎么寻找,如果一些联系人的电子邮件地址的值是

<t:EmailAddresses> 
    <t:Entry Key="EmailAddress1">/o=Server/ou=Exchange Administrative Group/cn=Recipients/cn=Testdeb</t:Entry> 
    <t:Entry Key="EmailAddress2">[email protected]</t:Entry> 
    </t:EmailAddresses> 

,而不是简单的字符串(EmailAddress1 VS EmailAddress2) 我不知道,如何使EmailAddress1值搜索从该位置

回答

0

作为使用FindItems的替代方法,您可以使用ResolveName操作来搜索联系人文件夹(与目录相反),如果您有EmailAddress,它将处理跨所有这些属性的搜索并返回匹配的条目。例如

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:m=" 
 
http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://sc 
 
hemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xml 
 
soap.org/soap/envelope/"> 
 
    <soap:Header> 
 
    <t:RequestServerVersion Version="Exchange2013" /> 
 
    </soap:Header> 
 
    <soap:Body> 
 
    <m:ResolveNames ReturnFullContactData="true" SearchScope="Contacts"> 
 
     <m:UnresolvedEntry>[email protected]</m:UnresolvedEntry> 
 
    </m:ResolveNames> 
 
    </soap:Body> 
 
</soap:Envelope>

然后,您可以绑定到基于EWSId触点在邮箱元素返回

干杯 格伦