question

GraemeTacon-6851 avatar image
0 Votes"
GraemeTacon-6851 asked saldana-msft edited

MS Graph List Mailfolders not returning all the folders

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-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I am unable to reproduce this on my end. What does $count=true operator return in your request? Are they sub folders of folders in the root of the mailbox?

0 Votes 0 ·

1 Answer

NovianWinangun-6161 avatar image
0 Votes"
NovianWinangun-6161 answered

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();



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.