标记电子邮件Java时出错

时间:2012-08-29 06:38:10

标签: java email

调用以下我的代码片段:

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

1 个答案:

答案 0 :(得分:5)

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