Six Stars

Jasper report outputs as email attachments (tJasperReportExec)

Hi , 

 

I want send jasper report outputs as email attachments

 

I am using tjasperReportExec. The job looks as shown below. If I have to send the report output as an attachment to multiple email addresses, how do I do it? As of now it stores the output in a directory. Also, if I have 10 different email and the report output differs for each email, how do I pick the relevant attachment and send it in tsendmail component? 

 

talendjasper.png

 

Also what is the difference between tjasperoutputexec, tjasperreportexec and tjasperoutput?

 

Any ideas on this will be of great help

 

Thanks

Rathi

1 ACCEPTED SOLUTION

Accepted Solutions
Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Hi fdenis, I figured it out

 

I had to use ((String)globalMap.get("tJasperReportExec_1_OUTPUT_FILE")) this in the attachment section of tsendmail.

 

Now, I have another problem. The job runs fine on windows, when I run it on linux, I get the error 

 

java.lang.Exception: No Connection or JRDataSource available to fill the report

 

But, I have used to tmysqlconnection to populate the connection details

 

Any help on this please?

 

 

22 REPLIES
Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

for multiple Email you can use semicolon(Smiley Wink as a separator. Also to send different to differ user user you can use Trigger then runif strategy.

Regards
Aashish
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

to send multiple reports, generate multiple report name using globalMap value of the tflowtoiterate.

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Hi Aashish,

 

I want it to loop, so I have used the tflowtoiterate. I want the report generated 10 times, each one containing the data specific for the email ID.

 

So, the relevant attachment needs to go to the correct email ID

 

My requirement is exactly the same as the solution in the video https://community.jaspersoft.com/blog/report-bursting-jasperreports-server

 

I read in a couple of articles that tjasperserverexec is not to be used as it is not updated regularly, hence using tjasperreportexec

 

Thanks

Rathi

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Hi fdenis,

 

Thanks, but, how do I attach it in the tsendmail? And how do I pick what is the relevant one for the specific email ID?

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

when you attache the document just add the output name of the report.

Define it unchecking "Use Default Output Name"

Fill Output name using distinct globalMap value as an email_id

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Hi fdenis,

 

In the attachment section of the tsendmail, I have used the code "C:/Users//report_out"+"_"+ ((Long)globalMap.get("row1.id"))+".xls"

 

And the tjasperreportexec has outputted these files already in the location mentioned above, report_out_1.xls, report_out_2.xls etc.

 

But I get the java.io.FileNotFoundException:  error.

 

I don't understand where is the error?

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Users//report --> Users/report

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Apologies, that was a typing error. The code used is Users/report and I get the file not found exception

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

did you want one report by mail or multiple reports by mail?
You can try using a fix file first?

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Okay the requirement is this. I have 4 email ids, abc@xxx.com, def@xxx.com, ghi@xxx.com and jkl@xxx.com

 

And the files outputted by tjasperreportexec is report_abc.xls, report_def.xls,report_ghi.xls, report_jkl.xls

 

So, for abc@xxx.com I must pick report_abc.xls , for def@xxx.com I must pick  report_def.xls etc

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

dose it work with a fix file

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Yes, it works for a fix file

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

try with a copy of your reports and dynamic file name

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

ahh.. I did not get you. Can you please elaborate?

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

dynamics name as attachment:
C:/Copy_Of_Users/report_out_"+ ((Long)globalMap.get("row1.id"))+".xls"

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

fdenis, I have used this code "C:/Users/report_out_"+ ((Long)globalMap.get("row1.id"))+".xls" and its still the same error

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

add tlog on row1 (check name of file générated)

I'm not on your desk!

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

fdenis, apologies for your time on a simple issue

 

I have checked  and the file name that is generated is correct and the file is present at the location mentioned

 

C:/Users/report_out_4.xls. This is the file name generated

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

try crate report first and to iterate a second time after a onSubjodOk to send emails

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

Hi fdenis, I figured it out

 

I had to use ((String)globalMap.get("tJasperReportExec_1_OUTPUT_FILE")) this in the attachment section of tsendmail.

 

Now, I have another problem. The job runs fine on windows, when I run it on linux, I get the error 

 

java.lang.Exception: No Connection or JRDataSource available to fill the report

 

But, I have used to tmysqlconnection to populate the connection details

 

Any help on this please?

 

 

Ten Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

it's an other topic.
just think about path they are with with \ only on windows
try to use // .
check file access too.
good luck

Francois Denis

Don't forget to tag when it's "solved"!

Six Stars

Re: Jasper report outputs as email attachments (tJasperReportExec)

hi fdenis,

 

Thank you for your support. I will start the discussion for being unable to run on linux machine as another topic