The original code that I have is:
var messages = await graphClient.Users["[email protected]"].MailFolders[folderName].Messages.GetAsync();
And I'm using Microsoft.Graph 5.2.0. Unfortunately, this only returns 10 emails at a time.
I tried the code that was posted to answer this question: Get all email message using Microsoft Graph API in c#. But, I'm having a problem with .Request method not being available. Here is the code that I am referring to:
var client = new GraphServiceClient(authenticationProvider);
var messages = await client.Users["[email protected]"].Messages
.Request()
.Top(100)
.GetAsync();
When I code that way. the .Request() is showing red squiggly saying MailFolderItemRequestBuilder does not contain a definition for 'Request'. Even upgrading to Microsoft.Graph 5.5.0 did not help.
Could someone please help me out?
In v5 you can specify the page size this way
var messages = await graphClient.Users["[email protected]"]
.MailFolders[folderName]
.Messages
.GetAsync(x =>
{
x.QueryParameters.Top = 100;
});
Other query options like Select
, Filter
, etc. are set with similar code.
Resources:
Query parameter options
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With