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();
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)
{
await msgs.NextPageRequest.GetAsync();
messages.AddRange(msgs.CurrentPage);
}
I think you should refer to this document :
Depending on the page size and mailbox data, getting messages from a mailbox can incur multiple requests. The default page size is 10 messages. To get the next page of messages, simply apply the entire URL returned in @odata.nextLink
to the next get-messages request. This URL includes any query parameters you may have specified in the initial request.
You can do it with .Top():
var client = new GraphServiceClient(authenticationProvider);
var messages = await client.Users["user@domain.com"].Messages
.Request()
.Top(100)
.GetAsync();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.