I am looping through a list of email attachments.
In this loop I am doing the following:
(Don't worry about the Core object, it works and returns a valid InputStream, tested this before by just reading out the bytes)
InputStream attachInputStream = Core.getFileDocumentContent(attachObject);
System.out.println("available for original stream: " + attachInputStream.available());
MimeBodyPart attachmentBodyPart = new MimeBodyPart(attachInputStream);
InputStream testStream = attachmentBodyPart.getInputStream();
System.out.println("available for retrieved stream: " + testStream.available());
attachmentBodyPart.setFileName(attachment.getName());
multipart.addBodyPart(attachmentBodyPart);
Because my received attachments were always empty, I added a few println's to check where this were going wrong. Following is the output when I run the application:
available for original stream: 119
available for retrieved stream: 0
So, apparently something goes wrong in the constructor for MimeBodyPart.
I hope I'm just doing something silly but I'm out of options at the moment apart of writing a lot of extra code to handle converting an InputStream to a MimeBodypart myself.
Anyone with some ideas?
edit: I just read I cannot use available after getting an inputstream from a mimebodypart. So I'll go and make another check. Problem still exists though, I'm not getting an attachment after mailing it.
Edited by: Bas_Rotterdam on Apr 15, 2009 3:16 AM