Is it possible to find a message not read using the java mail API?

I used java mail to read Gmail as follows:

Session session = Session.getDefaultInstance(props, null); Store store = session.getStore("imaps"); store.connect("imap.gmail.com", "mail", "password"); Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_WRITE); Message[] messages = folder.getMessages(); 

Now I want to find out if the message is unread, but cannot find any API. I want to do something like:

  for(Message message:messages) { if(message.isUnread) { // Do Something here } } 

There is no such API yet - isUnred.

+4
source share
1 answer

Have you tried Message.isSet (Flags.Flag.SEEN)

http://javamail.kenai.com/nonav/javadocs/javax/mail/Flags.Flag.html#SEEN

This message is visible. This flag is implicitly set by the implementation when the contents of this message are returned to the client in some form.

It has been a while since I used JavaMail, but I think that does what you want

+14
source

All Articles