Issue Reading Emails from a Custom Folder using Microsoft Graph API with Application Permissions

Paulino Cristovao 0 Reputation points
2024-03-18T01:42:38.3066667+00:00

Hello Microsoft Support Team,

I am encountering an issue while attempting to read emails from a custom folder named "Paris" in my Outlook mailbox using the Microsoft Graph API. I am developing a Python script that runs without user interaction, and I am the administrator and sole user of my Azure Active Directory (Azure AD).

Environment Details:

  • Azure AD Tenant ID: (Provide your tenant ID here)
  • Application ID: (Provide your application ID here)
  • Programming Language: Python
  • Libraries Used: MSAL for Python, Requests

Steps Taken:

  1. I registered my application in Azure AD and obtained the Application (client) ID and Directory (tenant) ID.
  2. I granted the following application permissions to my app: Mail.Read and User.Read, and I ensured admin consent was granted.
  3. I used the client credentials flow to acquire an access token.
  4. I attempted to list all mail folders to find the ID of the "Paris" folder and then read emails from this folder using the Microsoft Graph API.
  5. The script successfully lists mail folders, but when attempting to access the "Paris" folder's emails, I receive a 400 Bad Request response.

Expected Behavior: I expected to retrieve a list of emails from the "Paris" folder in my mailbox using the acquired access token and the Microsoft Graph API.Hello Microsoft Support Team,

I am encountering an issue while attempting to read emails from a custom folder named "Paris" in my Outlook mailbox using the Microsoft Graph API. I am developing a Python script that runs without user interaction, and I am the administrator and sole user of my Azure Active Directory (Azure AD).

Environment Details:

  • Azure AD Tenant ID: (Provide your tenant ID here)
  • Application ID: (Provide your application ID here)
  • Programming Language: Python
  • Libraries Used: MSAL for Python, Requests

Steps Taken:

  1. I registered my application in Azure AD and obtained the Application (client) ID and Directory (tenant) ID.
  2. I granted the following application permissions to my app: Mail.Read and User.Read, and I ensured admin consent was granted.
  3. I used the client credentials flow to acquire an access token.
  4. I attempted to list all mail folders to find the ID of the "Paris" folder and then read emails from this folder using the Microsoft Graph API.
  5. The script successfully lists mail folders, but when attempting to access the "Paris" folder's emails, I receive a 400 Bad Request response.

Expected Behavior: I expected to retrieve a list of emails from the "Paris" folder in my mailbox using the acquired access token and the Microsoft Graph API.

Outlook Windows Classic Outlook for Windows For business
Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Claudia Dos Santos Haz (CONCENTRIX CORPORATION) 1,120 Reputation points Microsoft External Staff
    2024-03-19T15:54:28.7+00:00

    Hi @Paulino Cristovao,

    Welcome to Microsoft Q&A and thanks for reaching out.

    To start please review the steps described below:

    https://learn.microsoft.com/en-us/graph/api/mailfolder-get?view=graph-rest-1.0&tabs=python

    Best regards,

    1 person found this answer helpful.
    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.