Trying to read all user mailbox using graph apis

Arun S 0 Reputation points
2023-06-16T06:54:17.22+00:00

Having a Single page application or a Web Application which allows admin to login to their microsoft account and provide consent to read users, mailboxes and get access token for the same.

Once thats done, able to read all users and for each user trying to read mailbox.

But apart from the user that has consented, unable to read any other user mailbox although the permissions are provided.

Following error is recvd when trying to read

{\'error\':{\'code\':\'ErrorItemNotFound\',\'message\':\'The specified object was not found in the store., Default folder AllItems not found.\',\'innerError\':{\'date\':\'2023-06-15T10:01:56\' ,\'request-id\':\'dfcf7847-73e8-4bff-a6a1-df6a32401f20\',\'client-request-id\':\'dfcf7847-73e8-4bff-a6a1-df6a32401f20\'}}}

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Konstantinos Passadis 19,586 Reputation points MVP
    2023-06-16T07:10:38.08+00:00

    Hello @Arun S !

    Welcome to Microoft QnA!

    can you kindly check this Thread :

    https://learn.microsoft.com/en-us/answers/questions/1117745/the-specified-object-was-not-found-in-the-store-de

    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.

    I hope this helps!

    Kindly mark the answer as Accepted and Upvote in case it helped!

    Regards

    0 comments No comments

  2. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2023-06-16T07:16:25.16+00:00

    Have followed the following pre-requisites to access user mailboxes through Graph API as

    • Assign API permissions to access your Exchange Online mailboxes from the following window

    User's image

    • Select Graph ‘Application permission’ for the purpose of mailbox access as below:

    User's image

    • Select the following permissions and save

    User's image

    • Grand Admin Consent to the selected permissions in the tenant. Finally, your permissions page will show as follows

    User's image

    Also, please refer the following article in my blog to see a similar requirement as yours

    Create Custom Folder in Exchange Online Mailboxes using Graph API using Windows PowerShell


    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

  3. Arun S 0 Reputation points
    2023-06-16T07:21:12.16+00:00

    Yes, i have followed the pre requisites and provided the application permissions.

    I am using One Org App to read Emails from Other Organisation using Client Credentails Flow by mentioning the required scope and getting consent by the admin.

    The Application used for the flow has all the permissions required to read.

    User's image


  4. Arun S 0 Reputation points
    2023-06-16T08:43:59.3533333+00:00

    Is there a way to indicate DELEGATE or APPLICATION Permission scope when trying to get Access token using OAUTH?

    I did read some where in the documentation which mentions that Mail read works only with Application permissions for other users.


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.