Reading from javamail takes a long time

后端 未结 4 1875
孤城傲影
孤城傲影 2021-02-15 15:57

I use javamail to read mails from an exchage account using IMAP protocol. Those mails are in plain format and its contents are XMLs.

Almost all those mails have short

4条回答
  •  后悔当初
    2021-02-15 16:41

    I had a similar issue. Fetching mails via IMAP were very slow. Furthermore I had another issue downloading large attachments. After a look in the JavaMail FAQ I found the solution for the later issue in this question that advises to set the mail.imap.partialfetch (respectively mail.imaps.partialfetch) to false. This not only fixes the download issue but the slow reading of the messages as well.

    In the referenced JavaMail notes.txt it is said.

    1. Due to a problem in the Microsoft Exchange IMAP server, insufficient number of bytes may be retrieved when reading big messages. There are two ways to workaround this Exchange bug:

      (a) The Exchange IMAP server provides a configuration option called "fast message retrieval" to the UI. Simply go to the site, server or recipient, click on the "IMAP4" tab, and one of the check boxes is "enable fast message retrieval". Turn it off and the octet counts will be exact. This is fully described at http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q191504

      (b) Set the "mail.imap.partialfetch" property to false. You'll have to set this property in the Properties object that you provide to your Session.

    2. Certain IMAP servers do not implement the IMAP Partial FETCH functionality properly. This problem typically manifests as corrupt email attachments when downloading large messages from the IMAP server. To workaround this server bug, set the "mail.imap.partialfetch" property to false. You'll have to set this property in the Properties object that you provide to your Session.

提交回复
热议问题