Access Shared Mailbox via Graph API

Piyush Payodhi 25 Reputation points
2023-10-27T15:25:24.84+00:00

Hi Team,
I want to read emails received in my organizations SharedMailBox though an inhouse API using Graph API. In order to do so I registered an application in MS Entra. Went to API permissions > Microsoft Graph > Application permissions, and then gave Mail.Read permissions. I was able to get the email data via the Graph api https://graph.microsoft.com/v1.0/users/{{mailbox email id}}/messages. But problem is that it gives me access to all the mailboxes including user mailbox. If I use delegated permissions, then I do not have any login associated with my SharedMailbox to give access to the application.

Microsoft Security Microsoft Graph
{count} vote

Accepted answer
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2023-10-27T16:30:40.45+00:00

    When using delegate permissions, the user under whose identity your code is running will need to have Full access permissions on the mailbox (which in turn means the user must have a mailbox on his own). On the Graph API side, make sure the Mail.Read.Shared scope has been granted. Then, use a request such as:

    https://graph.microsoft.com/v1.0/users/******@domain.com/messages?$top=1

    3 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. v-pd 10 Reputation points Microsoft External Staff
    2023-11-23T19:49:11.67+00:00

    If you want to access a shared mailbox, you can use the Mail.Read.Shared or Mail.ReadWrite.Shared permissions. These permissions only work for delegated permissions. You can access the shared mailbox and its messages like the following: https://graph.microsoft.com/v1.0/users/{sharedmailboxmailaddress}/messages.

    2 people found this answer helpful.

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.