Hi,
I'm using the Javamail API for processing messages from a Microsoft Exchange server (5.5). Everything is functioning great, except when the attachments on the emails greater than a few megs.
If I attach multiple attachments that equal ~6megs everything runs very quickly, but if I place a 3meg attachment into an email and try to process it pulling the attachment takes significantly longer
(20 seconds to pull the 6 megs of attachments under 2megs vs. 6 minutes to pull the 6 meg attachment).
Below is the code I am currently using (content is the BodyPart for the attachment, this.content is an instance byte[]):
try {
int buffer_size = 51200;
InputStream in=content.getInputStream();
ByteArrayOutputStream bos=new ByteArrayOutputStream();
byte[] buffer = new byte[buffer_size];
while(true) {
int n = in.read(buffer, 0, buffer_size);
if(n == -1) break;
bos.write(buffer, 0, n);
}
this.content = bos.toByteArray();
bos = null;
} catch (Exception e) {
e.printStackTrace();
}
I have played with the buffer sizes to no-avail. I have also set the partial fetch and fetchsize properties for the IMAP connection to on/off to no avail. I have also tried setting the heap size to 512megs.
Personally I think this is either a bug with the JavaMail IMAP implementation or maybe an issue with Exchange's IMAP Server (Thunderbird functions pretty quickly with it however).
Help would be greatly appreciated,
Thanks