The specified object was not found in the store., Default folder AllItems not found.

Benjamin Munyoki 21 Reputation points
2022-12-06T07:26:22.26+00:00

I am trying to read emails of users in a tenant. The admin has granted consent for the following permissions:

offline_access AccessReview.Read.All AccessReview.ReadWrite.All APIConnectors.ReadWrite.All Channel.ReadBasic.All ChannelMessage.Read.All ChannelSettings.Read.All Chat.Read ChatMessage.Read DelegatedPermissionGrant.ReadWrite.All Directory.Read.All Directory.ReadWrite.All Mail.Read Mail.Read.Shared Mail.ReadBasic Mail.ReadWrite MailboxSettings.Read openid profile TeamMember.Read.All TeamSettings.Read.All User.Read User.Read.All User.ReadBasic.All email  

I can read the emails of the admin (the signed in user) but not other users in the tenant.

https://graph.microsoft.com/v1.0/users/<email_of_signed_in_user>/messages works but https://graph.microsoft.com/v1.0/users/<email_of_any_other_user_in_the_tenant>/messages does not work but instead I get the below error:

"error": {
"code": "ErrorItemNotFound",
"message": "The specified object was not found in the store., Default folder AllItems not found.",
"innerError": {
"date": "2022-11-29T09:16:49",
"request-id": "2449c64a-9aa8-479d-8de4-923a2a306583",
"client-request-id": "5eb26a2e-54da-bba2-0adf-4fa7bca43df2"
}
}

What could be the issue? How do I read emails of users in a tenant with Oauth token? The admin has already granted the permissions in Azure AD.

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 46,371 Reputation points
    2022-12-06T08:38:09.18+00:00

    Hi @Benjamin Munyoki

    To read emails from other users within the tenant, you need to use the Mail.Read application permission, because the /users/{user id} endpoint only supports application context.

    267649-image.png

    Then use the daemon-based client credentials flow to obtain an access token.

    267549-image.png

    Call the API endpoint:

    267741-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


3 additional answers

Sort by: Most helpful
  1. Vicky Kumar (Mindtree Consulting PVT LTD) 1,161 Reputation points Microsoft Employee
    2022-12-06T09:44:35.807+00:00

    As per the error: Default folder AllItems not found , you can try with the specific mail folder.
    GET https://graph.microsoft.com/v1.0/users/{Other User's -userId | -userPrincipalName}/mailfolders('Inbox')/messages

    If that did not work, you can check the similar question to grant the permission on user's mailboxes on the Exchange Online Admin Center. - https://learn.microsoft.com/en-us/answers/questions/703996/outlook-open-another-mailbox-errorfoldernotfound.html

    Hope this helps

    Thanks

    0 comments No comments

  2. 春会 刀 25 Reputation points
    2023-03-06T10:10:11.6433333+00:00

    When I use the delegation method, I have encountered the same problem, I have authorized the permissions, but I still can't get the mail of other members in the organization, only the mail of the administrator.

    What should I do?


  3. Vuk Papić 0 Reputation points
    2023-11-13T14:59:51.3733333+00:00

    I have same problem but while creating events. I save in data base ids for all users. and load while creating event in calendar. But when other users try to create event that get next error
    "ErrorItemNotFound","message":"The specified object was not found in the store."

    this is Htpp request

    https://graph.microsoft.com/v1.0/users/{user_id}/calendars/{calendar_id}/events"
    
    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.