通过Domino Java代理,我使用Apache POI生成Excel电子表格。代码首先将文件保存到驱动器;我已经验证了我可以在那里打开文件,并且文件包含信息。然而,当我通过MIME将其附加到电子邮件中时,我会收到一条消息,说明"Excel无法打开文件电子表格.xlxs"one_answers"文件格式或文件扩展名无效"。
这是我正在使用的代码:
MIMEEntity ebody = maildoc.createMIMEEntity();
Stream outStream = session.createStream();
Stream inStream = session.createStream();
inStream.open(entry.getValue(),"binary");
do {
byte[] buffer = inStream.read(32767);
outStream.write(buffer);
} while(!inStream.isEOS());
inStream.close();
MIMEEntity child = ebody.createChildEntity();
child.setContentFromBytes(outStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", MIMEEntity.ENC_IDENTITY_BINARY);
MIMEHeader cdHeader = child.createHeader("Content-Disposition");
cdHeader.setHeaderVal("attachment; filename="spreadsheet.xlxs");
MIMEHeader idHeader = child.createHeader("Content-ID");
idHeader.setHeaderVal("spreadsheet.xlxs");
outStream.truncate();
outStream.close();
你知道我哪里错了吗?
xlsx,而不是xlxs。你错别字了。