SendHtml { public static void sendHtml(Email email) { sendHtml(email, email.getConnection()); }  static void sendHtml(Email email); static void sendHtml(Email email,
                                boolean debug); static void sendHtml(Email email,
                                Connection connection); static void sendHtml(Email email,
                                Connection connection,
                                boolean debug); static void collect(String body,
                               Message msg);  }
@Test public void sendHtmlWithAuthenticationAndAttachments() throws Exception { wiser.getServer().setAuthenticationHandlerFactory(new TestAuthHandlerFactory()); String testMethodName = Thread.currentThread().getStackTrace()[1].getMethodName(); String toAddress = "rgivens@kty.us.gov"; String fromAddress = "whawkins@kty.us.gov"; WorkItemImpl workItem = createEmailWorkItemWithAttachment(toAddress, fromAddress, testMethodName); Connection connection = new Connection(emailHost, emailPort, authUsername, authPassword); Email email = emailWorkItemHandler.createEmail(workItem, connection); SendHtml.sendHtml(email, connection); List<WiserMessage> messages = wiser.getMessages(); assertEquals(1, messages.size()); MimeMessage message = messages.get(0).getMimeMessage(); assertEquals(workItem.getParameter("Subject"), message.getSubject()); assertTrue(Arrays.equals(InternetAddress.parse((String) workItem.getParameter("To")), message.getRecipients(RecipientType.TO))); assertTrue(message.getContent() instanceof Multipart); Multipart multipart = (Multipart) message.getContent(); assertEquals(2, multipart.getCount()); for (int i = 0; i < multipart.getCount(); i++) { BodyPart bodyPart = multipart.getBodyPart(i); if (!Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition())) { continue; } assertEquals("email.png", bodyPart.getFileName()); } }