2016-07-05 78 views
1

使用下面的查詢,我在根文件夾下創建了一個搜索文件夾。它可以工作,但它也包括來自草稿文件夾的電子郵件。如何在創建搜索文件夾時排除草稿文件夾?

創建此搜索文件夾時,是否有直接排除草稿文件夾的方法?

<?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

由於所有限制都是基於項目的,因此您不能在EWS中使用搜索過濾器產生文件夾例外。因此,而不是在根開始搜索添加到您的每個子文件夾SearchFolder定義例如收件箱,SentItems等。

另一種選擇是增加一個限制,這將排除是目前使用未發送任何消息的位掩碼排除https://msdn.microsoft.com/en-us/library/office/dd633708(v=exchg.80).aspx在PR_MessageFlags財產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的任何文件夾中的任何消息。

+0

問題自行消失了!所以,我無法測試你的解決方案。但+1幫助我。 –

相關問題