开发者

is it possible to find if message is unread using java mail API?

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();

N开发者_如何学Goow 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜