* @throws Exception
*/
public static EmailAttachment zipAttachments(String attachmentName, EmailAttachment... attachments) throws FileNotFoundException, IOException, Exception {
HelperFile[] files = new HelperFile[attachments.length];
for (int i = 0; i < attachments.length; i++) {
EmailAttachment emailAttachment = attachments[i];
byte[] fileBytes = emailAttachment.getFileBytes();
if (fileBytes == null) {
fileBytes = IOHelper.getFileBytes(emailAttachment.getFile()); //in the case that this is a file on disk
}
files[i] = new HelperFile(fileBytes, emailAttachment.getAttachmentName());
}
byte[] zippedBytes = IOHelper.zipFiles(files);
return new EmailAttachment(zippedBytes, "attachments.zip", "application/zip", Message.ATTACHMENT);
}