I'm trying to generate an excel spreadsheet and then email it as an
attachment. The generation part works fine. I can save this to a file
and view it. I can attach an existing spreadsheet file to an email and
send it and it goes out ok. The problem is when I try to generate the
spreadsheet and attach it without saving it first.
This is what I'm doing:
1. Generate the workbook
2. Get the data byte array from the workbook using
HSSFWorkbook.getBytes()
3. Prepare a javax.activation.Datasource using this byte array where the
getInputStream method is as follows:
public InputStream getInputStream()
throws IOException
{
if (_data == null)
{
throw new IOException("no data");
}
return new ByteArrayInputStream(_data);
}
4. The emailer code itself, looks like this:
"Lost Document Summary Information"