1000 is the maximum number of items per page so you need something like this from https://learn.microsoft.com/en-us/graph/sdks/paging?tabs=csharp
var messages = await graphClient.Me.Messages
.Request()
.Header("Prefer", "outlook.body-content-type=\"text\"")
.Select(e => new {
e.Sender,
e.Subject,
e.Body
})
.Top(1000)
.GetAsync();
var pageIterator = PageIterator<Message>
.CreatePageIterator(
graphClient,
messages,
// Callback executed for each item in
// the collection
(m) =>
{
Console.WriteLine(m.Subject);
return true;
},
// Used to configure subsequent page
// requests
(req) =>
{
// Re-add the header to subsequent requests
req.Header("Prefer", "outlook.body-content-type=\"text\"");
return req;
}
);
await pageIterator.IterateAsync();
This will enumerate all the items in a the Folder so if you want to stop after 5000 you need to to put some logic to break after the number has been reached if you look at the second example on the docs page that gives an example of that.