我很少有主题为Report #123 : "Email_test_856" from test
的电子邮件。我正在尝试使用JavaMail API根据关键字Email_test
查找消息,但是它不会过滤掉任何消息。
这是我使用的代码:
public Message[] getMessages(String emailSubject, Folder folderInbox) throws MessagingException {
Message[] foundMessages = folderInbox.search(new SubjectTerm(emailSubject));
return foundMessages;
}
但是,如果我搜索主题为Email_test_856
或from test
,则消息将被过滤。
此外,如果我的邮件主题为Report #123 : "Email test 856" from test
,则搜索关键字为Email test
的效果很好。
您使用的是Gmail吗? Gmail仅会查找整个单词的字符串。参见Gmail restrictions in the FAQ的列表>