2014-11-21 45 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觸點在郵箱元素返回

乾杯 格倫