In my application, I am able to send emails and prepare Jasper Reports. I can send simple text based emails and even attach an image file to the content using Apache Commons-Emails. Also I am able to prepare reports using Jasper Reports with pdf and excel formats. The reported file is downloaded to my pc in any format without any problem. However, my question is I want to send the prepared report via the Apache Commons-Email to a user. That is, the report is ready and I can export its pdf format. I just want the exported pdf path and put it to my mail function. I am a new starter and I couldn't bind the two ready pieces in my app. Could you please shed a light to the matter. Any help would greatly be appreciated. Thank you in very much...
Below I am sending the prepared report and email functions so that it may help. In the "sendEmail()" function I just want to put prepared report path instead of image path in the example below. Or any other ways that could help.
public void sendEmail {// Create the attachmentEmailAttachment attachment = new EmailAttachment();attachment.setPath("mypictures/john.jpg"); // here I want to set the prepared report path so that it could be sent to the user.attachment.setDisposition(EmailAttachment.ATTACHMENT);attachment.setDescription("Picture of John");attachment.setName("John");// Create the email messageMultiPartEmail email = new MultiPartEmail();email.setHostName("smtp.googlemail.com");email.setSmtpPort(465);email.setAuthenticator(new DefaultAuthenticator("username", "password"));email.setSSLOnConnect(true);email.addTo("jdoe@somewhere.org", "John Doe");email.setFrom("me@apache.org", "Me");email.setSubject("The picture");email.setMsg("Here is the picture you wanted");// add the attachmentemail.attach(attachment);// send the emailemail.send();}[/code]
Send Email with pdf and excel attachments using Apache Commons Email and Jasper Report
in Products
Posted
In my application, I am able to send emails and prepare Jasper Reports. I can send simple text based emails and even attach an image file to the content using Apache Commons-Emails. Also I am able to prepare reports using Jasper Reports with pdf and excel formats. The reported file is downloaded to my pc in any format without any problem. However, my question is I want to send the prepared report via the Apache Commons-Email to a user. That is, the report is ready and I can export its pdf format. I just want the exported pdf path and put it to my mail function. I am a new starter and I couldn't bind the two ready pieces in my app. Could you please shed a light to the matter. Any help would greatly be appreciated. Thank you in very much...
Below I am sending the prepared report and email functions so that it may help. In the "sendEmail()" function I just want to put prepared report path instead of image path in the example below. Or any other ways that could help.
Prepare Jasper Report function:
send commons email function: