MS Graph List Mailfolders not returning all the folders

Graeme Tacon 1 Reputation point
2021-04-27T14:32:56.69+00:00

I'm using MS Graph to get all the folders in a mailbox using the following URL:

https://graph.microsoft.com/v1.0/users/{mailbox}/mailFolders

This returns 10 folders. I then use the URL returned in @odata.nextLink to call the API again, repeating this until there are no more. In total I get 39 folders returned.

But, when I look at the mailbox, it has far more than 39 folders. Why is MS Graph not returning them all - they are all under the same parent folder.

I've tried adding ?$top=100 at the end of the inital URL, but it still only returns 39.

Is this a bug in MS Graph ?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,521 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Novian Winangun 1 Reputation point
    2022-05-16T03:34:05.1+00:00

    Hi, have you found the answer?

    I am having a similar issue. I am not getting all the sub mailfolders of the parents unless the sub mailfolders were created by the application user that I used to access the inbox.
    I have applied all required permission for the application user.

    • Mail.ReadBasic.All
    • Mail.Read
    • Mail.ReadWrite

    I used the following code:

    var queryOptions = new List<QueryOption>()
    {
    new QueryOption("includeHiddenFolders", "true")
    };
    
    var TestOCFolders = await graphClient.Users[destination.Email].MailFolders[FolderId].ChildFolders.Request().GetAsync();
    
    var OCFolders = await graphClient.Users[destination.Email].MailFolders[FolderId].ChildFolders.Request(queryOptions).Top(250).GetAsync();
    
    0 comments No comments

  2. Dan Dunmore 0 Reputation points
    2023-03-06T12:12:12.1566667+00:00

    I was having the same issue while using the same URL.

    Not sure if this will be relevant to you - but I'm hoping it may be to someone else if not as this had me pulling my hair out.

    The mailbox I was running this against had been imported into MS365 from Gmail. As such, all of the imported folders had their PR_CONTAINER_CLASS value set to IPF.Imap, once I changed these to IPF.Note using MFCMAPI and relaunched Outlook the API call was returning them.

    0 comments No comments