I need to use this class ByteArrayDataSource to send an email with an attachment in it (a pdf created with iText) but our environment is running on java 1.4 but this class is in Javamail requires higher version.
I have to use this class as below:
//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);
Any suggestion?
You should be able to implement an equivalent class yourself from scratch. Look at the javadocs for the methods in the
DataSourceinterface, and it should be obvious how you need to implement them.(I’d do it for you, but I’ve written enough boring code for this week 🙂 )