Created
October 25, 2017 14:39
-
-
Save prabhatkashyap/c580db0630fc6c9d1808b8feb6df575b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Properties props = System.getProperties(); | |
props.setProperty("mail.store.protocol", "imaps"); | |
try { | |
Session session = Session.getInstance(props, null); | |
Store store = session.getStore("imaps"); | |
final String username = "" | |
final String password = "" | |
store.connect("imap.gmail.com", 993, username, password); | |
Folder inbox = store.getFolder("INBOX"); | |
inbox.open(Folder.READ_ONLY); | |
SearchTerm newerThan = new ReceivedDateTerm(ComparisonTerm.GT, new Date() - 6); | |
List messages = inbox.search(newerThan); | |
}catch(Exception e){} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment