Esempio n. 1
0
 private void lookForInvitation(Entity entity) {
   if (entity.isMultipart()) {
     Multipart multipart = (Multipart) entity.getBody();
     for (Entity part : multipart.getBodyParts()) {
       lookForInvitation(part);
     }
   } else {
     if (entity.getMimeType().equalsIgnoreCase("text/calendar")) {
       invitation = true;
     }
   }
 }
Esempio n. 2
0
 private void testEmailWithEmbeddedImage(SendEmail sendEmail) throws IOException {
   Message mimeMessage = sendEmail.getMimeMessage();
   Assertions.assertThat(mimeMessage.getMimeType()).isEqualTo("multipart/alternative");
   Body mainBody = mimeMessage.getBody();
   Assertions.assertThat(mainBody).isInstanceOf(Multipart.class);
   Multipart multipart = (Multipart) mainBody;
   Assertions.assertThat(multipart.getCount()).isEqualTo(2);
   Entity textPlain = multipart.getBodyParts().get(0);
   Entity secondPart = multipart.getBodyParts().get(1);
   Assertions.assertThat(textPlain.getMimeType()).isEqualTo("text/plain");
   Assertions.assertThat(secondPart.getMimeType()).isEqualTo("multipart/relative");
   Multipart multipartRelative = (Multipart) secondPart.getBody();
   Assertions.assertThat(multipartRelative.getCount()).isEqualTo(2);
   Entity htmlPart = multipartRelative.getBodyParts().get(0);
   Entity imagePart = multipartRelative.getBodyParts().get(1);
   Assertions.assertThat(htmlPart.getMimeType()).isEqualTo("text/html");
   Assertions.assertThat(imagePart.getMimeType()).isEqualTo("image/png");
   TextBody htmlTextBody = (TextBody) htmlPart.getBody();
   String htmlText = Joiner.on('\n').join(CharStreams.readLines(htmlTextBody.getReader()));
   Assertions.assertThat(htmlText)
       .contains("Galaxy S II")
       .contains("img src=\"cid:[email protected]\"");
   String contentId = imagePart.getHeader().getFields("content-id").get(0).getBody();
   Assertions.assertThat(contentId).isEqualTo("*****@*****.**");
 }