-
The following code throws IndexOutOfBoundsException. Any idea why?
Folder folder = store.getDefaultFolder(); folder = folder.getFolder("INBOX"); int totalMessages = folder.getMessageCount(); //totalMessages is 17000 folder.getMessages(16900, 16999) --- here I am trying to get the NEWEST 99 messages.
This code throws the exception indexoutofbounds even though there are so many mails. What am I doing wrong?
- folder.getMessages() – get all the emails from 1st email to last. In my case 17000!! How do I get the emails starting from newest to oldest?
I only want to see the latest emails – around 100 of them. Is this possible?
Never us magic values in code, it will just cause you pain. Try:
From the JavaDoc the messages are identified with a 1 based array not 0.
Can you also add the stack trace please.