4

调用以下代码后,我编写了代码片段:

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

我收到错误消息:

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

问题是什么?我可以调用诸如message_in.getSubject()但为什么不这样的方法message_in.setFlag()

4

1 回答 1

6

“在无效状态下收到 A9 NO 命令。” 表示 IMAP 文件夹(帐户)是只读的。

于 2012-08-29T12:24:56.997 回答