0

Does anyone know how to search for a user's flagged emails using the Outlook REST API?

The solution here: Flagged messages via Office 365 REST API? no longer seems to work. I've tried various versions of it with no luck. That solution does return without errors, but all I get are the first 10 messages in the user's inbox.

Community
  • 1
  • 1
Spaajanen
  • 383
  • 6
  • 15

2 Answers2

3

AidaNow is correct about the referenced link, it is not a filter. To filter for flagged messages, the recommended way would be to use the beta version of the API, which added the Flag property. Then you can filter like this:

GET https://outlook.office.com/api/beta/me/mailfolders/inbox/messages?$filter=Flag/FlagStatus eq 'Flagged'
Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
1

the solution in your referenced link is about expanding the flag property of a message when you are using a filter to get the messages, not filtering messages using the flag property. For example, in your case, you will get 10 messages in the response and each message may or may not have the 'SingleValueExtendedProperties' property, here is the rule:

if(message.SingleValueExtendedProperties == undefined){
 console.log(email has not been flagged/unflagged)
}else if(message.SingleValueExtendedProperties[0].Value == 2){
 console.log('email is flagged')
}else if(message.SingleValueExtendedProperties[0].Value == 1){
 console.log('email has been unflagged')
}

Back to your question about filtering using flag property, I have not seen any api call for that, but I will update my answer if I find any.

Community
  • 1
  • 1
AidaNow
  • 598
  • 5
  • 12