// }
// final ListenableFuture<FolderStatus> fStatus =
// client.statusOf("[Gmail]/All Mail");
ListenableFuture<Folder> future = client.open("[Gmail]/All Mail", true);
final Folder allMail = future.get();
// final FolderStatus folderStatus = fStatus.get();
// System.out
// .println("Folder opened: " + allMail.getName() + " with count " + folderStatus.getMessages());
final ExecutorService executor = Executors.newCachedThreadPool();
future.addListener(new Runnable() {
@Override
public void run() {
// final ListenableFuture<List<Integer>> messageStatuses =
// client.searchUid(allMail, "is:read", new Date(System.currentTimeMillis() - (500L * 24L * 60L * 60L * 1000L)));
final ListenableFuture<List<MessageStatus>> messageStatuses =
client.list(allMail, allMail.getCount() -5 , -1);
try {
// System.out.println(messageStatuses.get());
for (MessageStatus messageStatus : messageStatuses.get()) {
System.out.println(messageStatus);