private void addPartsToString(List<MailPart> list, StringBuilder sbd, String nextPartString) { int partCount = list.size(); for (int i = 0; i < partCount; i++) { Email attachment = list.get(i); String attachmentContent = attachment.getContent(); if (null != attachmentContent && 0 < attachmentContent.length()) { sbd.append(nextPartString).append(LINE_END); sbd.append("Content-Type: "); sbd.append(attachment.getContentType()); sbd.append(LINE_END); sbd.append("Content-Transfer-Encoding: "); sbd.append(attachment.getContentTransferEncoding()); sbd.append(LINE_END); String cd = attachment.getContentDisposition(); if (null != cd) { sbd.append("Content-Disposition: "); sbd.append(cd); sbd.append(LINE_END); } sbd.append(LINE_END); sbd.append(attachmentContent); sbd.append(LINE_END); } } }