i'm creating a BufferedImage
and i'm trying to include it to a MimeBodyPart
as follows:
BufferedImage img=generateQR(otp);
messageBodyPart = new MimeBodyPart();
File test = new File("phill.png");
ImageIO.write(img, "png", test);
DataSource fds = new FileDataSource(test);
messageBodyPart.setDataHandler(new DataHandler(fds));
messageBodyPart.setFileName("./phill.png");
messageBodyPart.setHeader("Content-ID", "<image>");
multipart.addBodyPart(messageBodyPart);
test.delete();
Is there any way to attach a BufferedImage
without creating a File
?
Please assume that
- generateQR() exists
- There is an HTML
MimeBodyPart