I have the following functions to get messages using Graph API
var client = new GraphServiceClient(authenticationProvider);
var messages = await client.Users["useer@domain.com"].Messages
.Request()
.GetAsync();
I am only able to get the latest 10 messages. How do I get all the messages? I tried to have a look at the microsoft documentation here: https://learn.microsoft.com/en-us/graph/api/message-get?view=graph-rest-1.0&tabs=csharp but unable to find any clues.
Found the answer after googling and trial error.
IUserMessagesCollectionPage msgs = await _client.Users[user@domain.com].Messages.Request()
.Filter("put your filter here")
.GetAsync();
List<Message> messages = new List<Message>();
messages.AddRange(msgs.CurrentPage);
while (msgs.NextPageRequest != null)
{
msgs = await msgs.NextPageRequest.GetAsync();
messages.AddRange(msgs.CurrentPage);
}