Using library Microsoft365R I can list the mails but it is always from the oldest and I can't figure out how to change it to list the latest mail first.
The below is the example code I am using and trying to sort by received desc and received asc gives the same output. Also listed 300 mails to show that there are more than 100 mails so the first 2 listings should have different max/min received dates
I am expecting the desc and asc to give different mails or if the number of mails is small it should be in a different order.
#Load library
library(Microsoft365R)
#setup environment
outlb <- get_business_outlook()
#by = "received desc"
mails_desc <- outlb$list_emails(by = "received desc",filter = "startswith(sender/emailAddress/address,'[email protected]')", n = 100)
#by = "received asc"
mails_asc <- outlb$list_emails(by = "received asc",filter = "startswith(sender/emailAddress/address,'[email protected]')", n = 100)
#listed 300 to show there are more than 100 emails
mails_300 <- outlb$list_emails(filter = "startswith(sender/emailAddress/address,'[email protected]')", n = 300)
Output showing the min/max receivedDateTime
#by = "received desc"
mails_desc[[1]]$properties$receivedDateTime [1] "2022-02-21T03:10:17Z" mails_desc[[100]]$properties$receivedDateTime [1] "2022-05-03T00:27:23Z"
#by = "received asc"
mails_asc[[1]]$properties$receivedDateTime [1] "2022-02-21T03:10:17Z" mails_asc[[100]]$properties$receivedDateTime [1] "2022-05-03T00:27:23Z"
#listed 300 to show there are more than 100 emails
mails_300[[1]]$properties$receivedDateTime [1] "2022-02-21T03:10:17Z" mails_300[[300]]$properties$receivedDateTime [1] "2022-09-26T01:28:59Z"