Пустой Excel отправлен через Java MailJAVA

Программисты JAVA общаются здесь
Anonymous
Пустой Excel отправлен через Java Mail

Сообщение Anonymous »

У меня есть Excel на своем местном диске, который я пытаюсь отправить по электронной почте. Содержание электронной почты успешно доставляется с помощью вложения Excel. Я использую ниже фрагмента < /p>
List recipentsList = getRecipientEmailAddresses(userManager, authorizable);
try {
LOGGER.info("File TRo Read is {}", reportFile);
File report = new File(reportFile);
FileOutputStream fos = new FileOutputStream(report);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
fos.write(bos.size()); // write excel data to a byte array
Map attachments = new HashMap();
attachments.put("report.xls", new ByteArrayDataSource(bos.toByteArray(), "application/vnd.ms-excel"));
String[] recipients = recipentsList.toArray(new String[0]);
LOGGER.info("Recipients :::: {}", Arrays.deepToString(recipients));
Map emailParams = new HashMap();
if (StringUtils.isNotEmpty(templatePath)) {
sendMailService.sendEmail(templatePath, emailParams,attachments, recipients, rr); // wrapper utility
}
fos.close();
} catch (IOException e) {
LOGGER.error("Error {}", e.getMessage());
}


Подробнее здесь: https://stackoverflow.com/questions/795 ... -java-mail

Вернуться в «JAVA»