Store imapsStore = getStore(imapHost, imapPort, userName, userPass, getProperties(),debugMail);
Folder givenFolder = imapsStore.getFolder(sourceFolder);
givenFolder.open(Folder.READ_ONLY);
/* Get the messages which is unread in the Inbox */
Message messages[] = givenFolder.search(new FlagTerm(new Flags(Flags.Flag.RECENT), true));
/* Use a suitable FetchProfile */
FetchProfile fp = new FetchProfile();
// fp.add(FetchProfile.Item.ENVELOPE);
// fp.add(FetchProfile.Item.FLAGS);
givenFolder.fetch(messages, fp);
This doesn’t return new mails from GMail. ? How To get It Work ? Does It Even Work ?
I know there is SEEN flag as well which is used to mark messages as READ/UNREAD, Im looking for Truly recent messages and not Unread messages.
Gmail doesn’t support \Recent.