The POI project consists of APIs for manipulating various file formats based upon Microsoft's OLE 2 Compound Document format, and Office OpenXML format, using pure Java. In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. POI is your Java Excel solution (for Excel 97-2007). However, we have a complete API for porting other OLE 2 Compound Document formats and welcome others to participate.
http://poi.apache.org/
I am able to manipulate a spreadsheet using Apache POI, I need to email the spreadsheet to certain recipients.
How do I email an HSSFWorkbook java object?
To send an email without the spreadsheet I am doing the following:
try {
String[] cmdarray = new String[4];
String emailBody = msg;
cmdarray[0] = "mail";
cmdarray[1] = "-s";
cmdarray[2] = subject;
cmdarray[3] = toList;
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(cmdarray);
BufferedOutputStream out = new BufferedOutputStream(p.getOutputStream());
out.write(emailBody.getBytes());
out.write("\n\n".getBytes()); //Closes the email editor and sends the mail.
out.close();
} catch(Throwable th) {
th.printStackTrace();
}
Please advise, thanks.






Bookmarks