We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ImapClient.ListMessages: Listing recent messages first

MailMessage msg = client.FetchMessage(msgInfo.UniqueId); is working for me, except one small issue. It fetches the messages in ascending order, which makes the latest message appear at the very end. I need to fetch the messages or sort them in descending with the latest message showing at the top.


Thank you,

Faruk

Hi Faruk,

Listing large number of messages from email server is not recommended as it can raise performance issues if the mailbox has thousands of emails. For your needs, you can filter messages from server based on your requirements like date-wise or retrieve only unseen using the ImapQueryBuilder . For your this requirement, we suggest you to filter messages from the server date-wise for each day. Then, you can traverse the collection from the end for this purpose. Please let us know if you have any further query in this regard.

ImapMessageInfoCollection msgsColl = retreived list of messages from server…

for (int i = msgsColl.Count; i > 0; i–)

{

Console.WriteLine(msgsColl[i].Subject);

//Do whatever you need from here onwards

}