Package org.apache.james.mime4j.message

Examples of org.apache.james.mime4j.message.Multipart


      return parts;
   }

   protected void extractParts() throws IOException
   {
      Multipart multipart = (Multipart) mimeMessage.getBody();
      for (BodyPart bodyPart : multipart.getBodyParts())
         parts.add(extractPart(bodyPart));
   }
View Full Code Here


            message.createMessageId(reportingMtaName);
            message.setSubject("Delivery Status Notification");
            message.setFrom(fromAddress.toMime4jMailbox());
            message.setTo(Mailbox.parse(originalMail.from.getSmtpText()));

            Multipart report = multipartReport();
            message.setMultipart(report,
                    Collections.singletonMap("report-type", "delivery-status"));
            return message;
        }
View Full Code Here

                    Collections.singletonMap("report-type", "delivery-status"));
            return message;
        }

        private Multipart multipartReport() {
            Multipart result = new Multipart("report");
            result.addBodyPart(humanReadableTextBodyPart());
            result.addBodyPart(deliveryStatusBodyPart());
            result.addBodyPart(originalMessageBodyPart());
            return result;
        }
View Full Code Here

        message.setTo(Mailbox.parse("Mary Smith <mary@example.net>"));
        message.setSubject("An image for you");

        // 3) set a multipart body

        Multipart multipart = new Multipart("mixed");

        // a multipart may have a preamble
        multipart.setPreamble("This is a multi-part message in MIME format.");

        // first part is text/plain
        BodyFactory bodyFactory = new BodyFactory();
        BodyPart textPart = createTextPart(bodyFactory, "Why so serious?");
        multipart.addBodyPart(textPart);

        // second part is image/png (image is created on the fly)
        BufferedImage image = renderSampleImage();
        BodyPart imagePart = createImagePart(bodyFactory, image);
        multipart.addBodyPart(imagePart);

        // setMultipart also sets the Content-Type header field
        message.setMultipart(multipart);

        // 4) print message to standard output
View Full Code Here

        // affecting the original.
        Message message = new Message(original);

        // In this example we know we have a multipart message. Use
        // Message#isMultipart() if uncertain.
        Multipart multipart = (Multipart) message.getBody();

        // Insert a new text/plain body part after every body part of the
        // template.
        final int count = multipart.getCount();
        for (int i = 0; i < count; i++) {
            String text = "Text inserted after part " + (i + 1);
            BodyPart bodyPart = createTextPart(text);
            multipart.addBodyPart(bodyPart, 2 * i + 1);
        }

        // For no particular reason remove the second binary body part (now
        // at index four).
        BodyPart removed = multipart.removeBodyPart(4);

        // The removed body part no longer has a parent entity it belongs to so
        // it should be disposed of.
        removed.dispose();

View Full Code Here

    /**
     * Creates a multipart/mixed message that consists of three parts (one text,
     * two binary).
     */
    private static Message createTemplate() throws IOException {
        Multipart multipart = new Multipart("mixed");

        BodyPart part1 = createTextPart("This is the first part of the template..");
        multipart.addBodyPart(part1);

        BodyPart part2 = createRandomBinaryPart(200);
        multipart.addBodyPart(part2);

        BodyPart part3 = createRandomBinaryPart(300);
        multipart.addBodyPart(part3);

        Message message = new Message();
        message.setMultipart(multipart);

        message.setSubject("Template message");
View Full Code Here

        sb.append("</header>\r\n");
       
        if (e.getBody() instanceof Multipart) {
            sb.append("<multipart>\r\n");
           
            Multipart multipart =(Multipart) e.getBody();
            List parts =multipart.getBodyParts();

            sb.append("<preamble>\r\n");
            sb.append(escape(multipart.getPreamble()));
            sb.append("</preamble>\r\n");
           
            int i = 1;
            for (Iterator it = parts.iterator(); it.hasNext();) {
                sb.append(getStructure((Entity) it.next(), prefix, id + "_" + (i++)));
            }

            sb.append("<epilogue>\r\n");
            sb.append(escape(multipart.getEpilogue()));
            sb.append("</epilogue>\r\n");
           
            sb.append("</multipart>\r\n");
           
        } else if (e.getBody() instanceof Message) {
View Full Code Here

      return parts;
   }

   protected void extractParts() throws IOException
   {
      Multipart multipart = (Multipart) mimeMessage.getBody();
      for (BodyPart bodyPart : multipart.getBodyParts())
         parts.add(extractPart(bodyPart));
   }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.message.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.