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(“nn”.getBytes()); //Closes the email editor and sends the mail.
out.close();
} catch(Throwable th) {
th.printStackTrace();
}
Please advise, thanks.