private static void appendAttachment(Multipart multipart, Attachment attachment) throws MessagingException { BodyPart fileBodyPart = new MimeBodyPart(); fileBodyPart.setDataHandler(new DataHandler(attachment.getDataSource())); fileBodyPart.setFileName(attachment.getFileName()); multipart.addBodyPart(fileBodyPart); }
public static AttachmentBuilder attachment(Attachment attach) { AttachmentBuilder builder = new AttachmentBuilder(); builder.fileName = attach.getFileName(); builder.contentType = attach.getContentType(); builder.thumbnail = attach.getThumbnail(); builder.fileSize = attach.getFileSize(); return builder; }