1

The query below searches inside a search folder. The query is supposed to match the subject or the body. It works for the subject field (and other fields that I tested with) but it does not work with the body field.

There are no error messages. It simply doesn't find any email that has the word "test" the body field.

The query works with all fields when I search the inbox instead of the search folder I created.

How do I search the body field when using a search folder?

  <?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>
          <t:BodyType>Best</t:BodyType>
        </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="test" />
           </t:Contains>
           <t:Contains ContainmentMode="Substring" ContainmentComparison="IgnoreCase">
             <t:FieldURI FieldURI="item:Body" />
             <t:Constant Value="test" />
           </t:Contains>
        </t:Or>  
        </m:Restriction>
        <m:ParentFolderIds>
          <t:FolderId Id="AQMkADAwATM3ZmYAZS1lOTAwAC0wMAA1ZS0wMAItMDAKAC4AAAPiAHaCXAJHRJ3V9VdvY0KtAQAj99d213jITaEDW4/40fguAAAAHOYgfgAAAA==" />  // root
        </m:ParentFolderIds>
      </m:FindItem>
    </soap:Body>
  </soap:Envelope>
nimatra
  • 604
  • 8
  • 19
Rayhan Muktader
  • 2,038
  • 2
  • 15
  • 32
  • Sounds like it cannot be done, see the comment of vangog below [the answer here](http://stackoverflow.com/a/36360014/512728) – Jan Doggen Jun 08 '16 at 14:47

1 Answers1

1

I tracked down our search folks internally. Unfortunately the body property isn't a searchable property. Doing a <Restriction> won't work properly for body.

Exchange does use the body (along with subject and attachment content) to create a "bag of words", which it can search into when you use a query string. So for example if you use the search box in Outlook or OWA and type in "foo", if foo is in the body of the message it would be included in the results.

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34