我的程序是这样的,由于邮件 有几十万条,如果一下全部接受,memory 会out,所以我设计成,每次500条,可是执行几轮后,老报下面的错误
while(true) {
Folder m_inbox = m_store.getFolder( "INBOX ");
m_inbox.open(Folder.READ_WRITE);
Message[] aMessages = m_inbox.getMessages();
int everyNum = 500;
if (aMessages.length <=everyNum) {
everyNum = aMessages.length;
}
for(int i=0;i <everyNum;i++){
Message message = aMessages[i];
if(message.isMimeType( "text/plain ")){ // 这里出错
insertdb(message);
}
message.setFlag(Flags.Flag.DELETED, true);
}
m_inbox.close(true);
}
出错消息
javax.mail.MessageRemovedException
at com.sun.mail.pop3.POP3Message.getContentStream(POP3Message.java:119)
at com.sun.mail.pop3.POP3Message.loadHeaders(POP3Message.java:435)
at com.sun.mail.pop3.POP3Message.getHeader(POP3Message.java:255)
at javax.mail.internet.MimeMessage.getContentType(MimeMessage.java:901)
at javax.mail.internet.MimeBodyPart.isMimeType(MimeBodyPart.java:836)
at javax.mail.internet.MimeMessage.isMimeType(MimeMessage.java:922)
at com.corp.pmc.mail.MailAgent.processPart(MailAgent.java:240)
at com.corp.pmc.mail.MailAgent.getNewMails(MailAgent.java:212)
at com.corp.pmc.server.PmcEmailCheckingTask.run(PmcEmailCheckingTask.java:54)
at java.util.TimerThread.mainLoop(Timer.java:510)
at java.util.TimerThread.run(Timer.java:460)
------解决方法--------------------------------------------------------
是不是拿的过程中有的邮件给删了还是什么?