[EMAIL PROTECTED] wrote:
Hi, Does anyone know how (and hopefully have some code sample for) the best way to take a HSSFWorkbook object and write it to Excel, and send it as an attachement to a mail (from a Java application), without having to write it to a file.
I'm using this code below, along with a Java mailer, but it's not quite working. The recipient does get an attachment, but it opens in excel with an error, and some of the formatting is lost in the process.
Anyone see the problem,.......or have some code that works? THANKS, Steve
String toAddress = repParams.getemailName(); String subject = repParams.getrptName(); try{ ByteArrayOutputStream os = new ByteArrayOutputStream(); hssfWorkbook.write(os); byte[] osByte = os.toByteArray(); Emailer em = new Emailer(Emailer.MAILER_FOR_REPORTS); em.createMail("Successfully sent the report","Report.xls",osByte); em.setToAddress(toAddress); em.setSubject(subject); em.sendEmail();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
