Javamail IMAP search by SUBJECT fails
Asked Answered
A

1

6

I'm using javamail for imap search by subject on Gmail. I use the subjectTerm class to create a searchTerm object and pass to the search function. Search works fine for subject strings which are pure alphanumeric. As soon as I put in a single quote or a dash in the search string the search fails.

IMAPSSLStore imapSslStore = connectToImap("imap.googlemail.com",993,email,oauthToken,oauthTokenSecret,getAnonymousConsumer(),true);

Folder inbox = imapSslStore.getFolder("[Gmail]/All Mail");
inbox.open(Folder.READ_ONLY);

SearchTerm sTerm = new SubjectTerm("String with quote's and da-sh"); //this fails

Message messages[] = inbox.search(sTerm);  //no results found !

Is there a standard way to escape the search string or this is a limitation on gmail's end?

Antecedents answered 22/10, 2010 at 14:16 Comment(0)
P
2

try using this api

http://code.google.com/p/java-gmail-imap/

Probable answered 15/12, 2011 at 20:34 Comment(1)
This doesn't answer the question. But asks the questioner to use a different solution altogether. What if multiple imap servers need to be searched some of which are google and some of which aren't?Ravishment

© 2022 - 2024 — McMap. All rights reserved.