我需要使用这个类ByteArrayDataSource发送一封附件(使用iText创建的pdf)的电子邮件,但是我们的环境在java 1.4上运行,但是此类在Javamail中需要更高版本。Java 1.4中的ByteArrayDataSource类
我有如下使用这个类:
//now write the PDF content to the output stream
outputStream = new ByteArrayOutputStream();
pdfCreator.createPdf(data,outputStream);
byte[] bytes = outputStream.toByteArray();
//construct the pdf body part
DataSource dataSource = **new ByteArrayDataSource**(bytes, "application/pdf");
MimeBodyPart pdfBodyPart = new MimeBodyPart();
pdfBodyPart.setDataHandler(new DataHandler(dataSource));
pdfBodyPart.setFileName("listadosCitaciones.pdf");
multipart.addBodyPart(messageBodyPart);
什么建议吗?
它的工作!我在一对网上找到了源代码,所以我只需要复制并粘贴它......我必须实现一对类,但幸运的是没有更多的依赖关系。 – dragonalvaro 2012-07-20 10:45:33