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.

Reply via email to