javax.mail.MessagingException:A4 NO COPY失败或部分完成

时间:2015-12-08 09:50:44

标签: java outlook javamail exchange-server

我试图在解析它们之后将Outlook电子邮件移动到另一个文件夹中,以便在Java中不再解析相同的电子邮件。代码工作正常,但有时它会在部分执行后抛出异常。我不确定是什么导致它。

例外:

Dec 07, 2015 4:55:50 PM email.TransferReadEmails removeReadEmails
SEVERE: ERROR!!A4 NO COPY failed or partially completed.
javax.mail.MessagingException: A4 NO COPY failed or partially completed.;
  nested exception is:
    com.sun.mail.iap.CommandFailedException: A4 NO COPY failed or partially completed.
    at com.sun.mail.imap.IMAPFolder.copyMessages(IMAPFolder.java:1553)
    at email.TransferReadEmails.transfer(TransferReadEmails.java:32)
    at email.TransferReadEmails.removeReadEmails(TransferReadEmails.java:65)
    at email.ReadingEmail.readEmails(ReadingEmail.java:146)
    at swingFrames.LaunchPanel.runProcess(LaunchPanel.java:994)
    at swingFrames.LaunchPanel.startOperationButtonMouseClicked(LaunchPanel.java:850)
    at swingFrames.LaunchPanel.access$600(LaunchPanel.java:48)
    at swingFrames.LaunchPanel$7.mouseClicked(LaunchPanel.java:191)
    at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
    at java.awt.Component.processMouseEvent(Component.java:6519)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6281)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4872)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4698)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:747)
    at java.awt.EventQueue.access$300(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:706)
    at java.awt.EventQueue$3.run(EventQueue.java:704)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:720)
    at java.awt.EventQueue$4.run(EventQueue.java:718)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:717)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: com.sun.mail.iap.CommandFailedException: A4 NO COPY failed or partially completed.
    at com.sun.mail.iap.Protocol.handleResult(Protocol.java:344)
    at com.sun.mail.iap.Protocol.simpleCommand(Protocol.java:366)
    at com.sun.mail.imap.protocol.IMAPProtocol.copy(IMAPProtocol.java:1479)
    at com.sun.mail.imap.protocol.IMAPProtocol.copy(IMAPProtocol.java:1461)
    at com.sun.mail.imap.IMAPFolder.copyMessages(IMAPFolder.java:1545)
    ... 39 more

我的代码:

//Function to copy and delete the messages from INBOX (Destination Folder: READ)
private static void transfer(Folder folder_source, Folder folder_dest, Message[] messages)
        throws Exception {       

    //If the READ folder does not exists create that folder
    if (!folder_dest.exists()) {
        folder_dest.create(Folder.HOLDS_MESSAGES);
    } 

    //Copy read messages from INBOX to READ folder
    folder_source.copyMessages(messages, folder_dest);

    //Delete the read messages from INBOX
    Flags deleted = new Flags(Flags.Flag.DELETED);
    folder_source.setFlags(messages, deleted, true);
    folder_source.expunge(); // or folder.close(true);


    System.out.println("Successfully");

    //Close the INBOX folder
    folder_source.close(false);
}

0 个答案:

没有答案