使用Javamail API和IMAP批量获取邮件正文 [英] Bulk Fetch Mail Bodies Using Javamail API and IMAP

查看:801
本文介绍了使用Javamail API和IMAP批量获取邮件正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过使用Javamail API一次调用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?

我知道我可以访问使用Message.getContent()调用给定消息的主体,但最终会为每个消息调用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.

是否可以使用FetchProfile和Folder.fetch调用批量获取主体?该文档暗示FetchProfile仅用于头数据。我尝试了以下方法,但是没有做到这一点:

Is it possible to use the FetchProfile and Folder.fetch call to bulk fetch bodies? The documentation implies that the FetchProfile is only for header data. I tried the following, but that didn't do the trick:

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

如果使用Javamail无法做到这一点,是否是由于Javamail API中的约束或者IMAP协议是否根本不支持?

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的限制。 IMAP协议允许一次获取多个消息的正文:

Limitation of JavaMail. The IMAP protocol allows fetching the bodies of several messages at once:

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

这篇关于使用Javamail API和IMAP批量获取邮件正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆