2016-05-31 11 views
0

Office.context.mailbox.makeEwsRequestAsyncメソッドを使用して、次のXMLクエリをEWSに送信します。"AND"と "OR"句を含むEWS検索クエリ

クエリ文字列の値は、subjectまたはfromフィールドのいずれかに一致する必要があります。電子メールは「MY_CATEGORY」カテゴリに属していなければなりません。私は最後の要件を強制することができません。私は間違って何をしていますか?

<?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="Exchange2013_SP1" /> 
    </soap:Header> 
    <soap:Body> 
     <m:FindItem Traversal="Shallow"> 
     <m:ItemShape> 
      <t:BaseShape>AllProperties</t:BaseShape> 
     </m:ItemShape> 
     <m:IndexedPageItemView MaxEntriesReturned="10" Offset="0" BasePoint="Beginning" /> 
     <m:Restriction> 
     <t:Or> 
      <t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase"> 
      <t:FieldURI FieldURI="item:Subject" /> 
      <t:Constant Value="query string" /> 
      </t:Contains> 
      <t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase"> 
      <t:FieldURI FieldURI="message:From" /> 
      <t:Constant Value="query string" /> 
      </t:Contains> 
     </t:Or> 
     <t:And> 
      <t:Contains ContainmentMode="FullString" ContainmentComparison="IgnoreCase"> 
      <t:FieldURI FieldURI="item:Categories" /> 
      <t:Constant Value="MY_CATEGORY" /> 
      </t:Contains> 
     </t:And> 
     </m:Restriction> 
     <m:ParentFolderIds> 
      <t:DistinguishedFolderId Id="inbox" /> 
      <t:DistinguishedFolderId Id="sentitems" /> 
     </m:ParentFolderIds> 
     </m:FindItem> 
    </soap:Body> 
    </soap:Envelope> 

答えて

0

カテゴリは複数値の文字列なので、検索フィルタを使用するとこれらのタイプの値は機能しません。 Exchange 2010以上のAQSを使用すると、検索したカテゴリだけでなく他のフィールドも検索できます。例えば

<?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="Exchange2013_SP1" /> 
 
    </soap:Header> 
 
    <soap:Body> 
 
     <m:FindItem Traversal="Shallow"> 
 
     <m:ItemShape> 
 
      <t:BaseShape>IdOnly</t:BaseShape> 
 
      <t:AdditionalProperties> 
 
      <t:FieldURI FieldURI="item:Subject" /> 
 
      <t:FieldURI FieldURI="item:DisplayTo" /> 
 
      <t:FieldURI FieldURI="item:DisplayCc" /> 
 
      <t:FieldURI FieldURI="item:DateTimeReceived" /> 
 
      <t:FieldURI FieldURI="item:HasAttachments" /> 
 
      <t:FieldURI FieldURI="item:ItemClass" /> 
 
      </t:AdditionalProperties> 
 
     </m:ItemShape> 
 
     <m:IndexedPageItemView MaxEntriesReturned="250" Offset="0" BasePoint="Beginning" /> 
 
     <m:SortOrder> 
 
      <t:FieldOrder Order="Ascending"> 
 
      <t:FieldURI FieldURI="contacts:DisplayName" /> 
 
      </t:FieldOrder> 
 
     </m:SortOrder> 
 
     <m:ParentFolderIds> 
 
      <t:FolderId Id="AQ..." /> 
 
     </m:ParentFolderIds> 
 
     <m:QueryString>System.Category:Green AND (From:'Glen Scales' OR Subject:test) </m:QueryString> 
 
     </m:FindItem> 
 
    </soap:Body> 
 
    </soap:Envelope>

+0

しかし、この作品は、複数のフォルダを持つのでしょうか?元のクエリが受信トレイと送信フォルダを検索していることに注目してください。 –

+0

javascript呼び出しを使用してEWS「検索フォルダ」を作成することはできますか? –

+0

複数のフォルダで正常に動作するはずですが、自分で試してみてください。たとえば、https://msdn.microsoft.com/en-us/library/office/dd633687(v=exchg.80)などのEWSを使用して検索フォルダを作成できます。 aspx –

関連する問題