File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes from my screen i wanted to send mail and from screen one report will generate that i wanted to send Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "from my screen i wanted to send mail and from screen one report will generate that i wanted to send " Watch "from my screen i wanted to send mail and from screen one report will generate that i wanted to send " New topic
Author

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

pallavi chaudhari
Ranch Hand

Joined: Jul 02, 2008
Posts: 54
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

Joined: Oct 27, 2005
Posts: 19541
    
  16

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.)


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
pallavi chaudhari
Ranch Hand

Joined: Jul 02, 2008
Posts: 54
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

Joined: Oct 27, 2005
Posts: 19541
    
  16

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

Joined: Jul 02, 2008
Posts: 54
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

Joined: Oct 27, 2005
Posts: 19541
    
  16

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[].
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: from my screen i wanted to send mail and from screen one report will generate that i wanted to send
 
Similar Threads
How to send mail from jsf, can anybody tell me the a-z guide for this
Generation of report
Synchronous and Asynchronous Report generation
create email delivery report
print Screen from a jsp