按主题进行的JavaMail搜索在某些子字符串中失败

问题描述 投票:0回答:1

我很少有主题为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_856from test,则消息将被过滤。

此外,如果我的邮件主题为Report #123 : "Email test 856" from test,则搜索关键字为Email test的效果很好。

java javamail imap
1个回答
1
投票

您使用的是Gmail吗? Gmail仅会查找整个单词的字符串。参见Gmail restrictions in the FAQ的列表>

© www.soinside.com 2019 - 2024. All rights reserved.