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);
}