Get Unread Mails From Inbox Using Microsoft Graph

How to get the count and collection of unread messages from Exchange using Microsoft Graph API.

Microsoft Graph is a unified API to access all services and data across Microsoft 365. In this blog, we will learn how to get the unread emails from the Inbox folder of the current user with the help of Microsoft Graph Explorer.
  • Navigate to Microsoft Graph Explorer using the URL - https://developer.microsoft.com/en-us/graph/graph-explorer/
  • Then, sign into the explorer using any of your Microsoft accounts.
  • Select the HTTP method as GET and then, select v1.0 as the API version.
  • Enter the below url iURLhe Graph Request URL box.

    https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=isRead ne true
  • The above URL filters the messages based on the isRead property from the Inbox folder. To get all the messages without a filter, remove the $filter parameter from the query.
  • To get the count of the unread messages from Inbox, we have to use $count as a query parameter in the request URL, as shown below.

    https://graph.microsoft.com/v1.0/me/mailFolders/Inbox/messages?$filter=isRead ne true&$count=true
Get UnRead Mails From Inbox Using Microsoft Graph
 
We will get the output as above after ruinning the Graph Request URL in Graph Explorer. Use this as a starting point to explore more features of Mail messages. We can try the same in any type of application.