I have the following code snippet that reads emails from the inbox.
try {
email.conectar();
javax.mail.Store store = email.getArquivoEmail();
Folder inbox = store.getFolder("inbox");
inbox.open(Folder.READ_ONLY);
//Aqui gostaria de pegar apenas e-mails dos últimos 10 dias.
for ( Message message : inbox.getMessages() ){
System.out.println("Mensagem: " + message.getSubject());
System.out.println("Data: " + ElfabDateUtils.formatDateOnly(message.getReceivedDate()));
}
} catch (MessagingException ex) {
logger.log(Level.SEVERE, null, ex);
}
But this code reads all the emails that are in the inbox, is there any way to add a filter to read from a date?