0

I cant find solution how to download multiple Emails with Multipart content with only one request to server (as batch fetching). The code i use:

FetchProfile lFp = new FetchProfile();
lFp.add(FetchProfile.Item.ENVELOPE);
lFp.add(FetchProfileItem.FLAGS);
lFp.add(FetchProfileItem.CONTENT_INFO);
pFolder.fetch(lMessages, lFp);

but when lMessages[i].getContent() is used, next request to server is performed. So for 50 next messages there are at least 50 more requests (+ nested Multiparts), it is not acceptable in my case. How to speed it up?

Bartek Szczypien
  • 333
  • 4
  • 17

2 Answers2

1

If you know that you always want to access all the content in the messages, you can use IMAPFolder.FetchProfileItem.MESSAGE.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
0

It would be simpler from what i have found, maybe i will check it in the future. Right now i use Justmaker's solution from this topic: JavaMail IMAP over SSL quite slow - Bulk fetching multiple messages

This method is incredible fast

EDIT: @Bill Shannon i have tried Your solution. It is more sophisticated and also download nested MultiPart content including attachments

Community
  • 1
  • 1
Bartek Szczypien
  • 333
  • 4
  • 17