java - Accessing emails from gmail using IMAP in Spring Boot -
i trying access emails gmail accounts through imap of javamail api.
i able access inbox folder of both email accounts. want view not read message, , number of it, possible ? thank in advance.
here code:
// retrieve messages folder in array , print message[] messages = emailfolder.getmessages(); system.out.println("messages.length---" + messages.length); (int = 0, n = messages.length; < n; i++) { message message = messages[i]; system.out.println("---------------------------------"); system.out.println("email number " + (i + 1)); system.out.println("subject: " + message.getsubject()); system.out.println("from: " + message.getfrom()[0]); system.out.println("text: " + message.getcontent().tostring()); }
the following line give unread messages count
system.out.println("unread count - " + folder.getunreadmessagecount());
and following line give unread messages
message[] unreadmessages = folder.search(new flagterm(new flags(flags.flag.seen), false));
hope helps you...
Comments
Post a Comment