Bulk Fetch Mail Bodies Using Javamail API and IMAP

2011-05-04T06:15:25

Is there a way to fetch the mail bodies of multiple emails with a single call to an IMAP server using the Javamail API?

I know I can get to the body of a given message using the Message.getContent() call, but this ends up doing a call to the imap server for each individual message.

Is it possible to use the FetchProfile and Folder.fetch call to bulk fetch bodies? The documentation implies that the FetchProfile is only for header data. I tried the following, but that didn't do the trick:

FetchProfile fp = new FetchProfile();
fp.add("rfc822.text");
inbox.fetch(messages, fp);

If it is not possible to do this using Javamail, is it due to a constraint in the Javamail API or does the IMAP protocol simply not support this?

Copyright License:
Author:「Canned」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/5876358/bulk-fetch-mail-bodies-using-javamail-api-and-imap

About “Bulk Fetch Mail Bodies Using Javamail API and IMAP” questions

Is there a way to fetch the mail bodies of multiple emails with a single call to an IMAP server using the Javamail API? I know I can get to the body of a given message using the Message.getContent()
JavaMail can only read one message at a time through IMAP. Threrefore, I am wondering whether opening several connections and reading emails concurrently is a good wordaround. Has anyone done this?...
how javamail imap fetch mail order by receive date desc? folder.getMessage() no a date arg. I want to sort by date when fetch mail in imap. Thanks Advance!
how javamail imap fetch mail order by receive date desc? folder.getMessage() no a date arg. I want to sort by date when fetch mail in imap. Thanks Advance!
I am trying to access Yahoo mail with IMAP using JavaMail API. I can connect to the Yahoo mail server successfully and am able to fetch the messages using folder.getMessages() call where folder is an
I am currently reading mail details via IMAP. I am able to collect all the details of Sender, subject and date received. If the mail has been replied, I need to collect the replied date as well. In...
Is there any better approach for sending bulk mail using JavaMail API.I use the below approach. enter code here Transport tr = session.getTransport("smtp"); tr.connect(smtphost, username, password...
I'm trying to connect to Exchange using Javamail and OAuth. I'm using Javamail 1.5.3 and I referred to this. 1) The exchange account that I'm trying to connect to is within an org domain. I know ...
I'm trying to read the emails in a folder of an email account Office365 using JavaMail 1.4 api. My code is: public static void main(String argv[]) throws Exception { // Get a Properties o...
I am using IMAP commands to fetch the mailbox data. Currently I am fetching mails one by one using mail id. But while reading large mailboxes its very slow. IMAP Command:"$ UID FETCH uid body[]\...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.