I am trying to access Yahoo mail with IMAP using JavaMail API. I can connect to the Yahoo mail server successfully and am able to fetch the messages using folder.getMessages()
call where folder is an object of javax.mail.Folder
class.
I need to iterate over all the messages returned by this call and I fetch received date of each message in this iteration. The iteration works well for small number of messages as it does not takes a long time, however if the number of returned messages is large (say around 10000) and iteration takes more than 30 minutes, then following exception occurs after 30 minutes:
javax.mail.FolderClosedException: * BYE IMAP4rev1 Server logging out
at com.sun.mail.imap.IMAPMessage.loadEnvelope(IMAPMessage.java:1234)
at com.sun.mail.imap.IMAPMessage.getReceivedDate(IMAPMessage.java:378)
at mypack.ImapUtils.getReceivedDate(ImapUtils.java:193)
...
Please note that I do not use the Folder object again during this iteration.
Could anyone please tell:
if there is a way to keep the folder open on yahoo mail server until it is explicitly closed?
if there is some property or setting which can be used to increase this "30 minutes" interval after which the folder is closed by the yahoo's IMAP server.
Thanks.