JavaMail BaseEncode64 Error

霸气de小男生 提交于 2019-12-01 17:24:39
RED

From a list of the known limitations, bugs, issues of JavaMail:

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.

So you should just turn off partial fetch in imap session. For example:

Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imap");
props.setProperty("mail.imap.partialfetch", "false");
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", "<username>","<password>");

source: https://javaee.github.io/javamail/docs/api/com/sun/mail/imap/package-summary.html

If You Are Using java mail API then add these lines while you are connectin the imap server......

Properties prop = new Properties();
prop.put("mail.imaps.partialfetch", false);
Session session = Session.getDefaultInstance(prop, null);

........ .... your code .. ......

it should work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!