Hi
I have a case where I am reading a set of emails using Aspose Email for Java in order to perform some processing.
I am using following example to get my list of emails in the inbox folder with Graph API:
GraphMessageInfoCollection collection = client.listMessages(inboxFolder.getItemId());
Is there a way to get oldest emails first?
Regards,
@elie.kach
We are working over your query and will get back to you soon.
@elie.kach
Unfortunately, the requested feature is not available in Aspose.Email for Java. We have logged it in our issue tracking system as EMAILJAVA-35091. You will be notified via this forum thread once it is available.
We apologize for your inconvenience.
@elie.kach
We have implemented the order by SentDate
capabilities of MSGraph client and this feature will be available in the next version of Aspose.Email for Java i.e. 22.8. You can use following code snippet with next version of Aspose.Email for Java 22.8.
for (int i = 0; i < 5; i++) {
MailMessage eml = new MailMessage(user.EMail, user.EMail, "ping_" + i, "test body");
client.send(MapiMessage.fromMailMessage(eml));
}
// waiting for inbox
Thread.sleep(10000);
// create orderby messages query 'DESC'
GraphQueryBuilder builder = new GraphQueryBuilder();
builder.getSentDate().orderBy(false);
MailQuery query = builder.getQuery();
GraphMessagePageInfo pageInfo = client.listMessages(GraphKnownFolders.Inbox, new PageInfo(10), query);
GraphMessageInfoCollection messages = pageInfo.getItems();
// check that newest is first
assertTrue(messages.get_Item(0).getSubject().endsWith("_4"));
// create orderby messages query 'ASC'
builder.clear();
builder.getSentDate().orderBy(true);
query = builder.getQuery();
pageInfo = client.listMessages(GraphKnownFolders.Inbox, new PageInfo(10), query);
messages = pageInfo.getItems();
// check that oldest is first
assertTrue(messages.get_Item(0).getSubject().endsWith("_0"));