final int attachmentsSize = mailDefinition.getAttachmentCount();
for (int i = 0; i < attachmentsSize; i++)
{
final MasterReport report = mailDefinition.getAttachmentReport(i);
final String type = mailDefinition.getAttachmentType(i);
final ContentLocation location = repository.getRoot();
final ContentLocation bulkLocation = location.createLocation("attachment-" + i);
final ReportProcessTask attachmentProcessTask = registry.createProcessTask(type);
attachmentProcessTask.setBodyContentLocation(bulkLocation);
attachmentProcessTask.setBodyNameGenerator(new DefaultNameGenerator(bulkLocation, "report"));
attachmentProcessTask.setReport(report);