Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Order, Paginate and List emails in JavaMail API

843834Aug 27 2008 — edited Sep 1 2008
Am able to sendm and retrieve emails in java using JavaMail API but am having a problem. I would like to sort emails by date, subject, sender etc and also display only a subset of emails using pagination.
            Message[] msgs = folder.getMessages();
            FetchProfile fp = new FetchProfile();
            fp.add(FetchProfile.Item.ENVELOPE);
            folder.fetch(msgs, fp);
The function folder.getMessages(); can take 2 arguments (from_index,to_index), but this is according to the way mail server will transalate. POP server will arrange by date while IMAP is unordered. I would like to order the mails then fetch the getMessages(from_index,to_index).
Another posible way am seeing is fetching all mesages using getMessages() put them in a temporary storage(eg. vector or list), order them and then fetch only the page i want. But this could be very costly in terms of processing resources, which makes me believe there is a better approach and it seems i cant find it.

Can somenone please advice me on what to do. I will be very greatful.

Edited by: kagara on Aug 27, 2008 12:27 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 29 2008
Added on Aug 27 2008
5 comments
859 views