I am working on a code to search my gmail account by subject and download attachment. Below is the code which I tried in 2 ways
but found returns 0. Can some one please help. Also I need to search if email has attachment as .xls


SearchTerm st = new SearchTerm()//XT_
{
@Override
public boolean match(Message message) {
try
{
if(message.getSubject().contains("XT_"))
{
return true;
}
}catch(MessagingException ex) {
ex.printStackTrace();
}
return false;

}

};
Message[] found = folderInbox.search(st);//returns 0

2) SubjectTerm bodyTerm = new SubjectTerm("XTIME_");

System.out.println("Searching for BodyTerm with keyword = "+ "XTIME_ ");

Message[] found = folderInbox.search(bodyTerm); // found returms 0