如何在创建搜索文件夹时排除草稿文件夹?

时间:2016-07-05 17:09:40

标签: exchangewebservices

使用下面的查询,我在根文件夹下创建了一个搜索文件夹。它有效,但它也包括来自草稿文件夹的电子邮件。

创建此搜索文件夹时是否有直接排除草稿文件夹的方法?

<?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
        xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
      <t:RequestServerVersion Version="Exchange2010" />
    </soap:Header>
    <soap:Body>
      <m:CreateFolder>
        <m:ParentFolderId>
          <t:DistinguishedFolderId Id="searchfolders" />
        </m:ParentFolderId>
        <m:Folders>
          <t:SearchFolder>
            <t:DisplayName> My_Search_Folder </t:DisplayName>
            <t:PermissionSet>
              <t:Permissions />
            </t:PermissionSet>
            <t:SearchParameters Traversal="Deep">
              <t:Restriction>
                <t:Contains ContainmentMode="FullString" ContainmentComparison="IgnoreCase">
                  <t:FieldURI FieldURI="item:Categories" />
                  <t:Constant Value="My_CATEGORY" />
                </t:Contains>
              </t:Restriction>
              <t:BaseFolderIds>
                <t:DistinguishedFolderId Id="root" />
              </t:BaseFolderIds>
            </t:SearchParameters>
          </t:SearchFolder>
        </m:Folders>
      </m:CreateFolder>
    </soap:Body>
  </soap:Envelope>

1 个答案:

答案 0 :(得分:1)

在EWS中,您无法使用搜索过滤器进行文件夹例外,因为所有限制都是基于项目的。因此,不要在根目录下启动搜索,而是将每个子文件夹添加到SearchFolder defination中,例如Inbox,SentItems等。

另一个选项是添加一个限制,通过在PR_MessageFlags属性https://msdn.microsoft.com/en-us/library/office/dd633708(v=exchg.80).aspx上使用BitMask排除https://msdn.microsoft.com/en-us/library/cc839733(v=office.12).aspx来排除当前未发送的任何消息,例如

        <m:Restriction>
          <t:Excludes>
            <t:ExtendedFieldURI PropertyTag="3591" PropertyType="Integer" />
            <t:Bitmask Value="8" />
          </t:Excludes>
        </m:Restriction>
这不会排除“草稿”文件夹中的邮件,但会排除在PR_MessageFlags属性中设置了Bitwise MSGFLAG_UNSENT的任何文件夹中的任何邮件。

相关问题