通过EmailAddress EWS搜索联系人

时间:2014-11-21 10:52:08

标签: soap exchangewebservices

我想通过EmailAddress搜索联系人。在代码

之后使用它
<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">secondtest@email.com</t:Entry>
  </t:EmailAddresses>

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

1 个答案:

答案 0 :(得分:1)

作为使用FindItems的替代方法,您可以使用ResolveName操作仅搜索contacts文件夹(而不是目录),如果您有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>frt@me.com</m:UnresolvedEntry>
    </m:ResolveNames>
  </soap:Body>
</soap:Envelope>

然后,您可以根据邮箱元素

中返回的EWSId绑定到联系人

干杯 格伦