Package javax.mail

Examples of javax.mail.Multipart


        sbuf.append(t);
      }

      part.setContent(sbuf.toString(), layout.getContentType());

      Multipart mp = new MimeMultipart();
      mp.addBodyPart(part);
      msg.setContent(mp);

      msg.setSentDate(new Date());
      Transport.send(msg);
    } catch (Exception e) {
View Full Code Here


            return null;
        }

        if (isMultipart())
        {
            Multipart multipart = (Multipartpart.getContent();
            if (partName.startsWith(MimeFileSystem.NULL_BP_NAME))
            {
                int partNumber = Integer.parseInt(partName.substring(MimeFileSystem.NULL_BP_NAME.length()), 10);
                if (partNumber < 0 || partNumber+1 > multipart.getCount())
                {
                    // non existent
                    return null;
                }

                return multipart.getBodyPart(partNumber);
            }

            for (int i = 0; i<multipart.getCount(); i++)
            {
                Part childPart = multipart.getBodyPart(i);
                if (partName.equals(childPart.getFileName()))
                {
                    return childPart;
                }
            }
View Full Code Here

        if (isMultipart())
        {
            Object container = part.getContent();
            if (container instanceof Multipart)
            {
                Multipart multipart = (Multipart) container;

                for (int i = 0; i<multipart.getCount(); i++)
                {
                    Part part = multipart.getBodyPart(i);

                    String filename = UriParser.encode(part.getFileName());
                    if (filename == null)
                    {
                        filename = MimeFileSystem.NULL_BP_NAME + i;
View Full Code Here

        // Complete the XML representation with the text part of the message
        Representation content = null;
        if (message.getContent() instanceof Multipart) {
            // Look for the text part of the mail.
            final Multipart multipart = (Multipart) message.getContent();

            for (int i = 0, n = multipart.getCount(); i < n; i++) {
                final Part part = multipart.getBodyPart(i);

                final String disposition = part.getDisposition();
                if (disposition != null) {
                    if (disposition.equals(Part.ATTACHMENT)
                            || disposition.equals(Part.INLINE)) {
View Full Code Here

        MimeBodyPart mainBody = new MimeBodyPart();
        mainBody.setText("This is the main message text");

        MimeBodyPart attachment = createBodyPart(TEST_MESSAGE, "message.txt");

        Multipart multipart = createMultipart(mainBody, attachment);

        MimeMessage message = getValidTransportMessage();
        message.setContent(multipart);
        return message;
    }
View Full Code Here

        mainBody.setText("This is the main message text");

        MimeBodyPart firstAttachment = createBodyPart("The first attachment content", "message.txt");
        MimeBodyPart secondAttachment = createBodyPart("The second attachment content", "message.txt");

        Multipart multipart = createMultipart(mainBody, firstAttachment, secondAttachment);

        MimeMessage message = getValidTransportMessage();
        message.setContent(multipart);
        return message;
    }
View Full Code Here

        return attachment;
    }

    private Multipart createMultipart(BodyPart... parts) throws MessagingException
    {
        Multipart multipart = new MimeMultipart();

        for (BodyPart part : parts)
        {
            multipart.addBodyPart(part);
        }

        return multipart;
    }
View Full Code Here

        super.addAttachments(muleMessage, transportMessage);

        Object content = ((Message) transportMessage).getContent();
        if (content instanceof Multipart)
        {
            Multipart multipart = (Multipart) content;

            TreeMap<String, Part> attachments = new TreeMap<String, Part>();
            MailUtils.getAttachments(multipart, attachments);

            log.debug("Received Multipart message. Adding attachments");
View Full Code Here

        for(int i = 0; i < content.getCount(); i++)
        {
            Part part = content.getBodyPart(i);
            if (part.getContentType().indexOf("multipart/mixed") > -1)
            {
                Multipart m = (Multipart) part.getContent();
                getAttachments(m, attachments);
            }
            else
            {
                String key;
View Full Code Here

                return null;
            }
           
            content = message.getContent();
            if (content instanceof Multipart) {
                Multipart multipart = (Multipart) content;
                for (int i = 0; i < multipart.getCount(); i++) {
                    try {
                        Part part = multipart.getBodyPart(i);
                        String fileName = part.getFileName();
                        if (fileName != null) {
                            return mail.getRecipients(); // file found
                        }
                    } catch (MessagingException e) {
View Full Code Here

TOP

Related Classes of javax.mail.Multipart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.