I was recently working on a similar project of parsing out email messages including attachment and got a lot of good info from:
http://java.sun.com/products/javamail/FAQ.html#readattach Hope it helps, garyj On Wed, Jul 9, 2008 at 11:37 AM, Ajay Chitre <[EMAIL PROTECTED]> wrote: > When an email comes in to my James server with one ore more attachments, I > need to get the attached files and save them someplace. Can someone > (please, please) provide a code snippet of processing email attachments > under James? > > I know I can get the file name as follows: > > try { > if (mail.getMessage().getContent() instanceof MimeMultipart) { > MimeMultipart mmp = (MimeMultipart) mail.getMessage().getContent(); > > for (int i = 0; i < mmp.getCount(); i++) { > MimeBodyPart mbp = (MimeBodyPart) mmp.getBodyPart(i); > System.out.println("File name: " + mbp.getFileName()); > } > } > } catch ( Exception e ) { > System.out.println("Error: " + e.getMessage()); > } > > > Do I need to write code to explicitly read the file using InputStream? Is > there a better way to do this? Any help in this regard will be greatly > appreciated. Thanks. >
