question

AndrewOmondi-5314 avatar image
0 Votes"
AndrewOmondi-5314 asked KeshavKishore-6268 published

Support filtering messages by body content

I've constructed the query below on Graph Explorer and got no messages in reply. My query.

https://graph.microsoft.com/v1.0/me/mailFolders('Inbox')/messages?$filter=subject eq '' and contains(body/content, '***')&$top=10

Do I understand correctly that a construct like 'contains(body/content, '')' verifies that the body contains the object I specified? And the whole body of the object shouldn't just consist of it?


Sourced from https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/1079

microsoft-graph-mail
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Danstan-MSFT avatar image
0 Votes"
Danstan-MSFT answered Danstan-MSFT edited

I don't think the body.content field is supported as filter item. In your case I think you may be better off with a search.

Try Search with filters and see if it gives what you are looking for.

 POST https://graph.microsoft.com/v1.0/search/query
 {
     "requests": [
         {
             "entityTypes": [
                 "message"
             ],
             "query": {
                 "queryString": "subject:'Lunch' AND somestring-that-will-match-content"
             }
         }
     ]
 }


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KeshavKishore-6268 avatar image
0 Votes"
KeshavKishore-6268 answered KeshavKishore-6268 published

@Danstan-MSFT The response for more than one query fails to give the output.

Request Json:

 {
     "requests": [
         {
             "entityTypes": [
                 "event"
             ],
             "query": {
                 "queryString": "subject: 'check' AND (summary: 'nznzz')"
             },
         }
     ]
 }

Request response:

 {
     "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(microsoft.graph.searchResponse)",
     "value": [
         {
             "searchTerms": [
                 "check",
                 "summary",
                 "nznzz"
             ],
             "hitsContainers": [
                 {
                     "total": 0,
                     "moreResultsAvailable": false
                 }
             ]
         }
     ]
 }

Request paylod:

 {
     "requests": [
         {
             "entityTypes": [
                 "event"
             ],
             "query": {
                 "queryString": "subject: 'check'"
             },
         }
     ]
 }

Response: { "value": [ { "searchTerms": [ "check" ], "hitsContainers": [ { "total": 2, "moreResultsAvailable": false, "hits": [ { "summary": "nznzz", "subject": "check" } ]}

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.