Closed GoogleCodeExporter closed 9 years ago
All looks to me so far!
You should be able to get the contents of the attachment by calling:
byte[] contents = attachment.getFileContents()
You'd probably want to throw it into a file or something (note: untested &
checked):
FileOutputStream out = new FileOutputStream(attachment.getLongFilename());
out.write(contents);
out.close();
Original comment by rjohnson...@gmail.com
on 29 Jul 2010 at 7:00
Wow with a couple tweaks it works! Just had to put a check in there to make
sure attachment.getFileSize() != 0 (else it would throw an exception)
Thanks again for the help and an amazing library.
Original comment by aneepbin...@gmail.com
on 30 Jul 2010 at 3:48
Cool, glad it's working for you. I've just bundled a new release which has
significant fixes and some new functions. It's recommended upgrading.
Original comment by rjohnson...@gmail.com
on 30 Jul 2010 at 4:01
Hi,i tried this code :
public static String parseMailAttachments(XHTMLContentHandler xhtml, PSTMessage email, EmbeddedDocumentExtractor embeddedExtractor)throws TikaException, IOException, PSTException, Exception {
int numberOfAttachments = email.getNumberOfAttachments();
String resulattachement=new String("");
for (int x = 0; x < numberOfAttachments; x++) {
PSTAttachment attach = email.getAttachment(x);
InputStream attachmentStream = attach.getFileInputStream();
// both long and short filenames can be used for attachments
String filename = attach.getLongFilename();
if (filename.isEmpty()) {
filename = attach.getFilename();
}
FileOutputStream out = new FileOutputStream(filename);
// 8176 is the block size used internally and should give the best performance
int bufferSize = 8176;
byte[] buffer = new byte[bufferSize];
int count = attachmentStream.read(buffer);
while (count == bufferSize) {
out.write(buffer);
count = attachmentStream.read(buffer);
}
byte[] endBuffer = new byte[count];
System.arraycopy(buffer, 0, endBuffer, 0, count);
out.write(endBuffer);
out.close();
attachmentStream.close();
}
return resulattachement;
}
}
and i have this error :
Caused by: java.io.FileNotFoundException: Invalid file path
Original comment by amiren...@gmail.com
on 20 Aug 2014 at 3:38
who can help me !!!!!!!!!!!!
Original comment by amiren...@gmail.com
on 21 Aug 2014 at 8:05
Original issue reported on code.google.com by
aneepbin...@gmail.com
on 29 Jul 2010 at 6:28