In java I need to get all emails from a specific sender. There are couple of ways to do that as shown here: http://www.codejava.net/java-ee/javamail/using-javamail-for-searching-e-mail-messages
But I need to have the process to be done on gmail side. It is not fine for me to read all emails and then decide which one I should proceed.
Also in http://alvinalexander.com/java/javamail-multiple-search-terms-pop3-mailbox-yahoo you can search message body which it is great, but what about the sender (FROM part)? How can I filter it?
Also reading all emails each time is not good for our bandwidth (Of course we can mark the last read email and read just all new emails somehow like using UIDFolder)
Thanks
I found it myself :)
All I needed was to add FromTerm!
If you need to use server HW to search emails from specific sender you should use IMAP command. You need ImapClient class and method ExecuteSearch(). Search IMAP commad for you is