Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javamail IMAP search by SUBJECT fails

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?

like image 885
Nands Avatar asked Oct 22 '10 14:10

Nands


1 Answers

try using this api

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

like image 94
x.509 Avatar answered Oct 06 '22 02:10

x.509