JavaMail reading recent unread mails using IMAP

前端 未结 4 1321
挽巷
挽巷 2020-12-10 02:46

I have a requirement to retrieve unread mails from Gmail. I am using Java Mail API. By default, this API retrieves mails from the oldest to newest. But I need to retrieve re

4条回答
  •  执念已碎
    2020-12-10 03:41

    JavaMail gives you an array of Message objects. The messages are in the order received. If you want to look at the most recently received messages first, go through the array in the reverse order. If you want to look at the most recently sent messages first, you'll need to sort the array, as described in the other answer.

提交回复
热议问题