I try to search all the mail boxes in the same time. But, in thread it's doesn't work. because I need keep connection. before question
Does anyone have any solution for this problem?
THANKS,
I try to search all the mail boxes in the same time. But, in thread it's doesn't work. because I need keep connection. before question
Does anyone have any solution for this problem?
THANKS,
没有一个 JavaMail 方法可以同时搜索所有邮箱,因为底层 IMAP 协议不支持这样的操作。您需要遍历所有邮箱并分别搜索每个邮箱。使用 Store.getDefaultFolder() 方法获取顶级文件夹,使用 Folder.list() 方法获取所有文件夹的列表。
这会帮助你
SearchTerm olderThan = new ReceivedDateTerm(ComparisonTerm.LT, someFutureDate);
SearchTerm newerThan = new ReceivedDateTerm(ComparisonTerm.GT, somePastDate);
SearchTerm andTerm = new AndTerm(olderThan, newerThan);
your_folder.search(andTerm);
如果您使用得当,线程不会影响您的机制。