Search code examples
javajakarta-mail

Sort Imap mails Based on arrival date


I am using IMAP protocol to fetch mails from Google server using java mail. Mails I retrieved are listed in descending order. How do I retrieve the most recent mail first based on arrival date?


Solution

  • Messages are stored as they arrive. The highest numbered message should be the most recent. Just access them in reverse order.