Andre Ahmed
Andre Ahmed

Reputation: 1891

Javamail java.lang.IllegalStateException: Folder is not Open

I'm trying to crawl an hotmail pop3 account which has about 4000+ messages. The problem is I couldn't download the whole email due to an exception that occurs at non-specific time at the following function :

recipients = message.getRecipients(type);

The exception is :

java.lang.IllegalStateException: Folder is not Open
    at com.sun.mail.pop3.POP3Folder.checkOpen(POP3Folder.java:539)
    at com.sun.mail.pop3.POP3Folder.getProtocol(POP3Folder.java:569)
    at com.sun.mail.pop3.POP3Message.loadHeaders(POP3Message.java:542)
    at com.sun.mail.pop3.POP3Message.getHeader(POP3Message.java:336)
    at javax.mail.internet.MimeMessage.getAddressHeader(MimeMessage.java:700)
    at javax.mail.internet.MimeMessage.getRecipients(MimeMessage.java:534)
    at edu.coeia.onlinemail.OnlineEmailDownloader.getAddress(OnlineEmailDownloader.java:568)

Upvotes: 2

Views: 10160

Answers (1)

Bill Shannon
Bill Shannon

Reputation: 29971

Most likely you closed the folder before accessing the content of the message. If you want to access the message content after closing the folder, you need to make a local copy of the message, either in memory or on disk.

Upvotes: 4

Related Questions