{
ArrayList<ByteArrayDataSource> htmlImageDataSources = new ArrayList<ByteArrayDataSource>();
ByteArrayDataSource byteArrayDataSource = exportReport(reportOutput, reportSchedule, htmlImageDataSources);
MailMessage mail = new MailMessage();
mail.setByteArrayDataSource(byteArrayDataSource);
mail.addHtmlImageDataSources(htmlImageDataSources);
mail.setSender(reportSchedule.getUser().getEmail());
mail.parseRecipients(reportSchedule.getRecipients());
mail.setBounceAddress(reportSchedule.getDeliveryReturnAddress());
if (reportSchedule.getScheduleDescription() != null && reportSchedule.getScheduleDescription().trim().length() > 0)
{
mail.setSubject(reportSchedule.getScheduleDescription());
}
else
{
mail.setSubject(reportSchedule.getReport().getName());
}
if (reportSchedule.getExportType() != ExportType.HTML.getCode())
{
mail.setText(reportSchedule.getReport().getName() + ": Generated on " + new Date());
}
try
{
mailProvider.sendMail(mail);
}
catch(ProviderException pe)
{
throw new DeliveryException(pe);
}
log.debug(byteArrayDataSource.getName() + " sent to: " + mail.formatRecipients(";"));
}