Upon calling the following I code snipit:
Message message_in = null;
inbox instanceof IMAPFolder
IMAPFolder f = (IMAPFolder)inbox;
f.idle();
System.out.println("IDLE done");
message_in = inbox.getMessage(inbox.getMessageCount());
message_in.setFlag(Flags.Flag.DELETED, true);
inbox.expunge();
I receive the error message:
javax.mail.MessagingException: A9 NO Command received in Invalid state.;
nested exception is:
com.sun.mail.iap.CommandFailedException: A9 NO Command received in Invalid state.
at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:905)
at javax.mail.Message.setFlag(Message.java:578)
at com.name.vmmonitor.main.VMMonitor.startPolling(VMMonitor.java:160)
at com.name.vmmonitor.main.VMMonitor.main(VMMonitor.java:283)
Caused by: com.sun.mail.iap.CommandFailedException: A9 NO Command received in Invalid state.
at com.sun.mail.iap.Protocol.handleResult(Protocol.java:351)
at com.sun.mail.imap.protocol.IMAPProtocol.storeFlags(IMAPProtocol.java:1589)
at com.sun.mail.imap.protocol.IMAPProtocol.storeFlags(IMAPProtocol.java:1574)
at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:901)
... 3 more
What is the issue? I am able to call methods such as message_in.getSubject() but why not message_in.setFlag()?
The “A9 NO Command received in Invalid state.” means the IMAP folder (the account) is read-only.