Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not Able to Set SEEN flag to mails read from gmail

Tags:

java

gmail

imap

I am using IMAP protocol to connet to my gmail account.

My application fails at this line. message.setFlag(Flags.Flag.SEEN, true);

And the log details are as follows:

[java] ---- exception report ----------------------------------------------------------
 [java] An error Occured while reading mail
 [java] Exception: javax.mail.MessagingException
 [java] Message: A10 NO STORE attempt on READ-ONLY folder (Failure)
 [java] ---- cause ---------------------------------------------------------------------
 [java] Exception: com.sun.mail.iap.CommandFailedException
 [java] Message: A10 NO STORE attempt on READ-ONLY folder (Failure)
 [java] ---- stack trace ---------------------------------------------------------------
 [java] com.sun.mail.iap.CommandFailedException: A10 NO STORE attempt on READ-ONLY folder (Failure)
 [java] com.sun.mail.iap.Protocol.handleResult(Protocol.java:294)
 [java] com.sun.mail.imap.protocol.IMAPProtocol.storeFlags(IMAPProtocol.java:1294)
 [java] com.sun.mail.imap.protocol.IMAPProtocol.storeFlags(IMAPProtocol.java:1279)
 [java] com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:843)
 [java] javax.mail.Message.setFlag(Message.java:565)

Any help will be appreciated.

Thanks, Kumaraswamy.N

like image 403
user395607 Avatar asked Jul 19 '10 08:07

user395607


1 Answers

It looks like you opened your folder as READ_ONLY. Make sure you are doing

folder.open(Folder.READ_WRITE)

when you open your folder.

BTW POP protocol doesn't recognize Flags. So I'm surprised it works for POP since you should be getting an IllegalWriteException when using POP. Regardless, message.setFlag(...) won't do anything with POP.

like image 197
Nikordaris Avatar answered Sep 23 '22 00:09

Nikordaris