简体   繁体   English

使用 Javamail API 和 IMAP 批量获取邮件正文

[英]Bulk Fetch Mail Bodies Using Javamail API and IMAP

Is there a way to fetch the mail bodies of multiple emails with a single call to an IMAP server using the Javamail API?有没有办法使用 Javamail API 一次调用 IMAP 服务器来获取多封电子邮件的邮件正文?

I know I can get to the body of a given message using the Message.getContent() call, but this ends up doing a call to the imap server for each individual message.我知道我可以使用 Message.getContent() 调用获取给定消息的正文,但这最终会为每个单独的消息调用 imap 服务器。

Is it possible to use the FetchProfile and Folder.fetch call to bulk fetch bodies?是否可以使用 FetchProfile 和 Folder.fetch 调用来批量获取正文? The documentation implies that the FetchProfile is only for header data.该文档暗示 FetchProfile 仅适用于 header 数据。 I tried the following, but that didn't do the trick:我尝试了以下方法,但这并没有奏效:

FetchProfile fp = new FetchProfile();
fp.add("rfc822.text");
inbox.fetch(messages, fp);

If it is not possible to do this using Javamail, is it due to a constraint in the Javamail API or does the IMAP protocol simply not support this?如果使用 Javamail 无法做到这一点,是由于 Javamail API 中的限制还是 IMAP 协议根本不支持这个?

Limitation of JavaMail. JavaMail 的限制。 The IMAP protocol allows fetching the bodies of several messages at once: IMAP 协议允许一次获取多条消息的正文:

a1 fetch 1:* (rfc822.header rfc822.text)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM