I'm trying to download a complete message with all headers and body content, and show a progress while the transfer is in progress.
I can't find any API giving access to progress information while fetching, so the best (ugly hack) solution I've come up with is using folder.doCommand() and swapping out the Protocol.input stream with a wrapped version while doing
fetch(msgNum, "body[]")
and then putting the unwrapped inputStream back after fetch using Reflection.
Then I create a new MimeMessage from the FetchResponse using the
new MimeMessage(session, inputstream)
constructor. The inputstream is retrieved from the
FetchResponse.getItem(0)).data
property. This stream contains the FETCH command on the first line and the ending ) on the last. I would like a clean inputstream with just the message content, and the ability to monitor the download progress. Please advice :)
Sincerely,
Edvin Syse