Package javax.mail

Examples of javax.mail.BodyPart


    }

    protected void addBodyToMultipart(MailConfiguration configuration, MimeMultipart activeMultipart, Exchange exchange)
        throws MessagingException, IOException {

        BodyPart bodyMessage = new MimeBodyPart();
        populateContentOnBodyPart(bodyMessage, configuration, exchange);
        activeMultipart.addBodyPart(bodyMessage);
    }
View Full Code Here


    public String toString(Message message) throws MessagingException, IOException {
        Object content = message.getContent();
        if (content instanceof MimeMultipart) {
            MimeMultipart multipart = (MimeMultipart) content;
            if (multipart.getCount() > 0) {
                BodyPart part = multipart.getBodyPart(0);
                content = part.getContent();
            }
        }
        if (content != null) {
            return content.toString();
        }
View Full Code Here

    @Converter
    public static String toString(Multipart multipart) throws MessagingException, IOException {
        int size = multipart.getCount();
        for (int i = 0; i < size; i++) {
            BodyPart part = multipart.getBodyPart(i);
            if (part.getContentType().startsWith("text")) {
                return part.getContent().toString();
            }
        }
        return null;
    }
View Full Code Here

            // select the plain text bodypart
            String messageBody = null;
            if (wrapper.getMainPartCount() > 1) {
                for (int ind=0; ind < wrapper.getMainPartCount(); ind++) {
                    BodyPart p = wrapper.getPart(ind + "");
                    if (p.getContentType().toLowerCase().indexOf("text/plain") > -1) {
                        messageBody = (String) p.getContent();
                        break;
                    }
                }
            }
View Full Code Here

            try {
                container =(MimeMultipart) part.getContent();
                int count = container.getCount();
                parts = new SimpleMessageAttributes[count];
                for (int i = 0; i < count ; i ++) {
                    BodyPart nextPart = container.getBodyPart(i);

                    if (nextPart instanceof MimePart) {
                        SimpleMessageAttributes partAttrs = new SimpleMessageAttributes();
                        setupLogger(partAttrs); // reset transient logger
                        partAttrs.parseMimePart((MimePart)nextPart);
View Full Code Here

                System.out.println("This part contains " + count + " parts.");
                parts = new SimpleMessageAttributes[count];
                for (int i = 0; i < count ; i ++) {
                    getLogger().info("Getting embedded part: " + i);
                    System.out.println("Getting embedded part: " + i);
                    BodyPart nextPart = container.getBodyPart(i);

                    if (nextPart instanceof MimePart) {
                        SimpleMessageAttributes partAttrs = new SimpleMessageAttributes();
                        setupLogger(partAttrs); // reset transient logger
                        partAttrs.parseMimePart((MimePart)nextPart);
View Full Code Here

        MimeMultipart multi = (MimeMultipart)o;
        int numOfParts = multi.getCount();
       
        boolean hasTheAttachment = false;
        for (int i = 0; i < numOfParts; i++) {
            BodyPart bp = multi.getBodyPart(i);
            String disp = bp.getDisposition();
            if (disp == null) {                        //the body of the email
                Object innerContent = bp.getContent();
                MimeMultipart innerMulti = (MimeMultipart)innerContent;
                assertEquals(emailBody, innerMulti.getBodyPart(0).getContent());
            } else if (disp.equals(Part.ATTACHMENT)) { //the attachment to the email
                hasTheAttachment = true;
                assertEquals(ATTACHMENT_NAME, bp.getFileName());
            } else {
                fail("Did not expect to be able to get here.");
            }
        }
        assertTrue(hasTheAttachment);
View Full Code Here

      String body = "";
      if (message.getContent() instanceof String) {
        body = message.getContent().toString();
      } else if (message.getContent() instanceof Multipart) {
        Multipart multipart = (Multipart) message.getContent();
        BodyPart bodypart = multipart.getBodyPart(0);
        body = bodypart.getContent().toString();
      }

      // check line 1: "The results of the evaluation:"
      if (body.indexOf("The results of the evaluation:") == -1) {
        System.out.println("fail 1");
View Full Code Here

      String body = "";
      if (message.getContent() instanceof String) {
        body = message.getContent().toString();
      } else if (message.getContent() instanceof Multipart) {
        Multipart multipart = (Multipart) message.getContent();
        BodyPart bodypart = multipart.getBodyPart(0);
        body = bodypart.getContent().toString();
      }

      // check line 1: "The results of the evaluation:"
      if (body.indexOf("The results of the evaluation:") == -1) {
        System.out.println("fail 1");
View Full Code Here

        } else if (message.getContent() instanceof Multipart) { // if
                                    // its a
          // multipart
          // message
          Multipart multipart = (Multipart) message.getContent();
          BodyPart bodypart = multipart.getBodyPart(0);
          body = bodypart.getContent().toString();
        }

       
        String key = body.split(courseId+":")[1];
        key = key.split("\\*")[0].trim();
 
View Full Code Here

TOP

Related Classes of javax.mail.BodyPart

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.