Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you email the contents of a Printable?

Status
Not open for further replies.

mes123

Programmer
Jul 29, 2005
62
0
0
GB
I've got a printable Jpanel (and a printable class called printMe), is it possible to (easily) convert these and email them?
 
I think you'll need to explain yourself a little more. At first sight, I don't understand the concep of "email a panel"

Cheers,
Dian
 
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.

 
there is no way to do it directly without having to save to a file first?
 
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).

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top