I was using java mail to read Gmail as following -
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 wan to find out if message is unread, but could not find any API. I want to do something like -
for(Message message:messages) {
if(message.isUnread) {
// Do Something here
}
}
While there is no such API - isUnred.
Have you tried Message.isSet(Flags.Flag.SEEN)
http://javamail.kenai.com/nonav/javadocs/javax/mail/Flags.Flag.html#SEEN
This message is seen. This flag is implicitly set by the implementation when the this Message's content is returned to the client in some form
it's been a while since I used JavaMail, but I think that does what you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With