Try something like this, suitably modified of course...

        try {
            MimeMultipart mp = (MimeMultipart)message.getContent();
            int partCount = mp.getCount();
            for (int i = 0; i < partCount; i++) {
                MimeBodyPart part = (MimeBodyPart)mp.getBodyPart(i);
                ContentType contentType = new
ContentType(part.getContentType());
                String partType = contentType.getBaseType();
                if (attachmentMatches(part)) {
                    imagePart = part;
                }
            }
        }
        catch (IOException iox) {
            throw new MessagingException("Failed to process message
attachments", iox);
        }

Note that this doesn't recurse through nested parts.

Steve

> -----Original Message-----
> From: Patrick Han [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, July 09, 2002 9:28 AM
> To: [EMAIL PROTECTED]
> Subject: How to Extract Attachment from an Incoming Mail
> 
> 
> Dear all,
> 
> I am new to JAMES and this mailing list.  Please excuse me if 
> I ask silly questions. :)
> 
> I am currently developing a mailet that should intercept with 
> an incoming mail and save the attachment (This will always be 
> an image, mostly in .jpg) to a local directory residing on 
> the mail server.  However, I have gone through the JAMES and 
> Mailet API and found various methods to extract almost all 
> parameters of a mail but the actual email attachment!
> 
> I have also searched all over the Web to look for related 
> topic but most of the searching result I got is related to 
> how to send attachment via email, not to extract attachment 
> from an email.
> 
> Does anyone has any clue on how I can proceed with this task? 
>  Thanks in advance!
> 
> Pat
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to