小编Ric*_*cky的帖子

使用android中的javamail根据日期时间检索电子邮件

我正在完成检索电子邮件的任务.我设法使用以下代码检索.但是,它从gmail收件箱中的最早到最新的电子邮件中检索收到的电子邮件.有没有办法让它检索到最新的邮件?我打算实现一种方法来检索最新的20封邮件,而不是检索收件箱中的所有邮件.提前感谢您的指导.

public ArrayList<HashMap<String, String>> getMail(int inboxList){
        Folder inbox;
         /*&nbsp; Set the mail properties&nbsp; */
         Properties props = System.getProperties();
         props.setProperty("mail.store.protocol", "imaps");
         try
         {
             /*&nbsp; Create the session and get the store for read the mail. */
             Session session = Session.getDefaultInstance(props, null);
             Store store = session.getStore("imaps");
             store.connect("imap.gmail.com",username, password);

             /*&nbsp; Mention the folder name which you want to read. */
             inbox = store.getFolder("Inbox");
             System.out.println("No of Unread Messages : " + inbox.getUnreadMessageCount());
             /*Open the inbox using store.*/
             inbox.open(Folder.READ_WRITE);
             /*&nbsp; Get the messages which is …
Run Code Online (Sandbox Code Playgroud)

android jakarta-mail

3
推荐指数
1
解决办法
5259
查看次数

标签 统计

android ×1

jakarta-mail ×1