List of usage examples for javax.mail.internet MimeBodyPart equals
public boolean equals(Object obj)
From source file:com.adaptris.core.mail.attachment.MimeMailCreator.java
/** * @see MailContentCreator#createAttachments(com.adaptris.core.AdaptrisMessage) *//* w ww . j a v a2 s . c o m*/ @Override public List<MailAttachment> createAttachments(AdaptrisMessage msg) throws MailException { if (bodySelector == null) { throw new MailException("No way of selecting the body"); } List<MailAttachment> attachments = new ArrayList<MailAttachment>(); try { BodyPartIterator mp = MimeHelper.createBodyPartIterator(msg); MimeBodyPart body = bodySelector.select(mp); for (int i = 0; i < mp.size(); i++) { MimeBodyPart attachment = mp.getBodyPart(i); if (!attachment.equals(body)) { ByteArrayOutputStream out = new ByteArrayOutputStream(); StreamUtil.copyStream(attachment.getInputStream(), out); out.flush(); attachments.add(new MailAttachment(out.toByteArray(), getAttachmentFileName(attachment), getContentType(attachment)) .withContentTransferEncoding(getContentTransferEncoding(attachment))); } } } catch (Exception e) { throw new MailException(e); } return attachments; }