Carl, Here is some code from the service() routine of a mailet I use to grab jpg's from attachments:

                // Loop through the attachments
                //
                // Have a look at:
                // 
http://java.sun.com/developer/onlineTraining/JavaMail/contents.#GettingAttachments
                // for some tips on saving attachements.
                //

                try {
                        MimeMessage msg = (MimeMessage) mail.getMessage();
                        Multipart mp = (Multipart) msg.getContent();
                        boolean imageFound = false;
                        for (int j = 0, n = mp.getCount(); j < n; j++) {
                                Part part = mp.getBodyPart(j);

                                String disposition = part.getDisposition();
                                String contentType = part.getContentType();

                                log("Content Type = " + contentType + " Disposition 
= "
                                                + disposition);

                                if (contentType.startsWith("image/jpeg")) {
                                        imageFound = true;
                                        saveImage(user, part);
                                }
                        }
                        if (imageFound) {
                                sendImageReceived(recipient, sender, user);
                                
                        } else {
                                sendImageNotReceived(recipient, sender, user);
                        }
                } catch (Exception e) {
                        log("Error: ", e);
                }


Hope this helps.  -- Bud


Carl Vorster wrote:
Hi,

Is it possible to access/process a mail attachment from a mailet, I can't
seem to find anything to point me in the right direction.

Thanks in advance

Carl


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




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

Reply via email to