• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

from my screen i wanted to send mail and from screen one report will generate that i wanted to send

 
pallavi chaudhari
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,


In my project I have to send a mail about some confirmation report.But how can i attach that report without saving anywhere?
is there any way?

 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a File, you usually use a DataHandler with a FileDataSource:
All you need to do then is replace the FileDataSource with another class that implemens javax.activation.DataSource; I think you'll like ByteArrayDataSource. (And of course set the file name differently.)
 
pallavi chaudhari
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:With a File, you usually use a DataHandler with a FileDataSource:
All you need to do then is replace the FileDataSource with another class that implemens javax.activation.DataSource; I think you'll like ByteArrayDataSource. (And of course set the file name differently.)


This is my code:


Calling sendMail............



Now...need to do...

from Button present in my screen onClick of that Jasper report will be generate & I have to convert it to pdf.....and i do not know i can show this report but for sending it as attachment whether i need to store it under WEB-INF directory in some folder? how can I store it?

 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can probably convert the report to an in-memory PDF using ByteArrayOutputStream. Then call toByteArray() on the latter and pass it to a ByteArrayDataSource as I told you.
 
pallavi chaudhari
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:You can probably convert the report to an in-memory PDF using ByteArrayOutputStream. Then call toByteArray() on the latter and pass it to a ByteArrayDataSource as I told you.


Now I have used DataSource.......


calling sendMail:




To Generate Report:



To convert to PDF




But still not found solution.................???
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I'm wrong, but doesn't buf now contain the PDF in a byte array? If so, I've told you how to create a DataSource for that byte[].
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic