问题描述
根据,
Message[] msgs = folder.getMessages();
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
folder.fetch(msgs, fp);
但是,如果我想通过search()只获取读取的消息,我不会有一种方法可以指定一个FetchProfile(因为search()没有这样的参数)。
However, if I want to get only the read messages by using search(), I don't have a means to specify a FetchProfile (as search() doesn't take such a parameter).
Folder inbox = store.getFolder("Inbox");
inbox.open(Folder.READ_WRITE);
FlagTerm ft = new FlagTerm(new Flags(Flags.Flag.SEEN), false);
Message messages[] = inbox.search(ft); //how to specify a FetchProfile here ??
还有其他办法吗?
谢谢提前很多。
推荐答案
我不相信你可以。
在这里,JavaMail镜像底层的IMAP命令 - 首先你找出你感兴趣的消息集,然后通过一个单独的命令获取这些消息的数据。没有办法强制IMAP服务器从SEARCH命令返回FetchProfile风格的数据,而JavaMail只是符合IMAP对什么时候返回的约束。
In this, JavaMail mirrors the underlying IMAP commands -- first you figure out the set of messages that you're interested in, then you fetch data on those messages via a separate command. There's no way to coerce an IMAP server to return you FetchProfile-style data from a SEARCH command, and JavaMail is just conforming to IMAP's constraints on what gets returned when.
这篇关于Javamail:在搜索邮件时可以使用FetchProfile而不是仅仅获取邮件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!