I've got a JPanel that implements the Prinatble interface, it's used to display an invoice. I wanted to know if it's possible to send an email that will contain the 'image' of the jPanel.
As far as I understand the JavaMail API you cannot simply set a Printable as the content of an email and I don't know how to convert the jPanel contents to a form which can be emailed.
The easiest way to attach data to an email is like so :
Code:
mbp = new MimeBodyPart();
mbp.setFileName(file.getName());
mbp.setDataHandler(new DataHandler(new FileDataSource(file)));
mp.addBodyPart(mbp);
Now, while you could of course create your own implementation of javax.activation.DataSource - which allowed you to attach images, byte data, or whatever you wanted, I'm guessing you are a newbie, and I really would go down the path of least resistance (ie attaching a file).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.