private static Content getContentWithAttachments(MimePart part) throws MessagingException, IOException { Content result = new Content(); String rootId = new ContentType(part.getContentType()).getParameter("start"); MimeMultipart mp = (MimeMultipart) part.getContent(); for (int i = 0; i < mp.getCount(); i++) { MimePart p = (MimePart) mp.getBodyPart(i); if (isRootPart(p, i, rootId)) { result = result.merge(processPart(p, part)); } else { result.attachments.add(p); } } return result; }
private static Content getContent(MimePart part) throws IOException, MessagingException { Content result = new Content(); result.body = (String) part.getContent(); result.type = part.getContentType(); return result; }