How can I fetch outlook account's email data of all the users in my organization account.

Anns 61 Reputation points
2022-12-15T17:57:33.497+00:00

I am trying to fetch the outlook accounts email data of all the users added to my organization account. But unfortunately, I am getting the following error.
Endpoint I Tried: https://graph.microsoft.com/v1.0/me/mailFolders('Inbox')/messages
The response I got:
{
"error": {
"code": "MailboxNotEnabledForRESTAPI",
"message": "The mailbox is either inactive, soft-deleted, or is hosted on-premise.",
"innerError": {
"date": "2022-12-15T17:49:30",
"request-id": "e8f44438-4f2b-4fc4-aad4-11cf6c4258d0",
"client-request-id": "e8f44438-4f2b-4fc4-aad4-11cf6c4258d0"
}
}
}
What could be the reason for the error and how I can fix it?

Outlook | Windows | Classic Outlook for Windows | For business
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
{count} votes

1 answer

Sort by: Most helpful
  1. Shivam Dhiman 6,081 Reputation points
    2022-12-15T20:08:26.487+00:00

    Hi @Anns

    You are getting this error because no Exchange Online mailbox is available to use. The Azure ad user for which you are trying to get messages do not have a valid M365 license.

    Please provide the valid M365 License to the user.

    Also, for more details please refer to this similar case.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.