Examples of Multipart


Examples of javax.mail.Multipart

     */
    private boolean isContainAttach(Part part) throws Exception {
        boolean attachflag = false;
//        String contentType = part.getContentType();
        if (part.isMimeType("multipart/*")) {
            Multipart mp = (Multipart) part.getContent();
            for (int i = 0; i < mp.getCount(); i++) {
                BodyPart mpart = mp.getBodyPart(i);
                String disposition = mpart.getDisposition();
                if ((disposition != null)
                        && ((disposition.equals(Part.ATTACHMENT)) || (disposition.equals(Part.INLINE)))) {
                    attachflag = true;
                } else if (mpart.isMimeType("multipart/*")) {
View Full Code Here

Examples of javax.mail.Multipart

        }
    }

    private boolean matchPart(Part part) throws MessagingException, IOException {
        if (part.isMimeType("multipart/*")) {
            Multipart mp = (Multipart) part.getContent();
            int count = mp.getCount();
            for (int i=0; i < count; i++) {
                BodyPart bp = mp.getBodyPart(i);
                if (matchPart(bp)) {
                    return true;
                }
            }
            return false;
View Full Code Here

Examples of javax.mail.Multipart

            msg.addHeader("X-Jenkins-Result", context.getBuild().getResult().toString());
        }
        msg.setSentDate(new Date());
        setSubject(context, msg, charset);

        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(getContent(context, charset));

        AttachmentUtils attachments = new AttachmentUtils(attachmentsPattern);
        attachments.attach(multipart, context);

        // add attachments from the email type if they are setup
View Full Code Here

Examples of javax.mail.Multipart

      }
      else if (content instanceof javax.mail.Message)  {
        handleMessage(directory, (javax.mail.Message) content, emailFragments);
      }
      else if (content instanceof Multipart) {
        final Multipart mp2 = (Multipart) content;
        handleMultipart(directory, mp2, mailMessage, emailFragments);
      }
      else {
        throw new IllegalStateException("Content type not handled: " + content.getClass().getSimpleName());
      }
View Full Code Here

Examples of javax.mail.Multipart

    if (content instanceof String) {
      emailFragments.add(new EmailFragment(new File(subject), "message.txt", content));
    }
    else if (content instanceof Multipart) {
      Multipart multipart = (Multipart) content;
      handleMultipart(directoryToUse, multipart, mailMessage, emailFragments);
    }
    else {
      throw new IllegalStateException("This content type is not handled - " + content.getClass().getSimpleName());
    }
View Full Code Here

Examples of javax.mail.Multipart

    private void assertOnMailResult(User user, VerificationToken token) throws MessagingException, IOException {
        List<MimeMessage> messages = mailSender.getMessages();
        assertThat(messages.size(), is(1));
        MimeMessage message = messages.get(0);
        assertThat(message.getAllRecipients()[0].toString(), is((user.getEmailAddress())));
        Multipart multipart = (Multipart)message.getContent();
        String content = (String)multipart.getBodyPart(0).getContent();
        assertThat(content, containsString(new String(Base64.encodeBase64(token.getToken().getBytes()))));
    }
View Full Code Here

Examples of javax.mail.Multipart

        addresses[toIndex++] = new InternetAddress(t);
      }
      msg.setRecipients(Message.RecipientType.TO, addresses);
      msg.setSubject(subject);
      msg.setSentDate(new Date());
      final Multipart mp = new MimeMultipart();
      final MimeBodyPart mbp1 = new MimeBodyPart();
      mbp1.setText(message);
      mp.addBodyPart(mbp1);
      if (paths != null && paths.length > 0) {
        for (final Path path : paths) {
          final MimeBodyPart mbp = new MimeBodyPart();
          final FileDataSource fds = new FileDataSource(path.toFile());
          mbp.setDataHandler(new DataHandler(fds));
          mbp.setFileName(fds.getName());
          mp.addBodyPart(mbp);
        }
      }
      // text attachment
      // MimeBodyPart mbp2 = new MimeBodyPart();
      // mbp2.setText("some text in an attachment form");
View Full Code Here

Examples of javax.mail.Multipart

      log.debug("Checking message body for commands");
      String msgRawContent = null;
      if (msg.getContentType().toLowerCase().indexOf("text") > -1) {
        msgRawContent = (String) msg.getContent();
      } else if (msg.getContentType().toLowerCase().indexOf("multipart") > -1) {
        final Multipart multipart = (Multipart) msg.getContent();
        BodyPart bodyPart = multipart.getBodyPart(0);
        msgRawContent = bodyPart.getContent().toString();
      } else {
        log.warn("Commands being ignored for content type: " + msg.getContentType());
      }
      if (msgRawContent != null) {
View Full Code Here

Examples of javax.mail.Multipart

        assertNull(message.getRecipients(RecipientType.CC));
        assertNull(message.getRecipients(RecipientType.BCC));
        assertEquals(1, message.getRecipients(RecipientType.TO).length);
        assertEquals(recipient, message.getRecipients(RecipientType.TO)[0]);
        assertTrue(message.getContent() instanceof Multipart);
        Multipart multipart = (Multipart) message.getContent();
        assertEquals(2, multipart.getCount());
        assertEquals("text/plain; charset=\"iso-8859-1\"", multipart.getBodyPart(0).getContentType());
        assertEquals(plaintext, multipart.getBodyPart(0).getContent());
        assertEquals(plaintext, new GaeEmailUtils().getTextPart(message));
        assertEquals("text/html; charset=\"iso-8859-1\"", multipart.getBodyPart(1).getContentType())// seems like this ought to be text/html ???
        assertEquals(html, multipart.getBodyPart(1).getContent());
        assertEquals(html, new GaeEmailUtils().getHtmlPart(message));
    }
View Full Code Here

Examples of javax.mail.Multipart

        assertNull(message.getRecipients(RecipientType.CC));
        assertNull(message.getRecipients(RecipientType.BCC));
        assertEquals(1, message.getRecipients(RecipientType.TO).length);
        assertEquals(recipient, message.getRecipients(RecipientType.TO)[0]);
        assertTrue(message.getContent() instanceof Multipart);
        Multipart multipart = (Multipart) message.getContent();
        assertEquals(2, multipart.getCount());
        assertEquals("text/plain; charset=\"iso-8859-1\"", multipart.getBodyPart(0).getContentType());
        assertEquals(plaintext, multipart.getBodyPart(0).getContent());
        assertEquals(plaintext, new GaeEmailUtils().getTextPart(message));
        assertEquals("text/html; charset=\"iso-8859-1\"", multipart.getBodyPart(1).getContentType())// seems like this ought to be text/html ???
        assertEquals(html, multipart.getBodyPart(1).getContent());
        assertEquals(html, new GaeEmailUtils().getHtmlPart(message));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.