1
I have the following piece of code that performs the reading of 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);
}
However this code reads all the emails that are in the inbox, there is some way to add a filter so that the reading is done from a date?