Overview#

This sample demonstrates how to send a Jasper report via email.

The sample uses the Sun mail api to send two jasper reports in one email. The first report is sent as a PDF attachment while the second report is sent as the body of the email including automatically embedding any required images into the email.

SendMail contains a test driver and is the logical starting place.

Note: the JasperReport class is my own wrapper class.

Known issues:#

  • The code has had only limited testing.
  • It uses two jasper reports which aren't included in the sample code (just add your own).
  • When attaching images to the email it doesn't appear to be possible to determine the
image type from Jasper. The sample code uses 'image/gif' for all image types. Even when wrong this appears to work in at least outlook. If your concerned about this limiation then either make certain that all of your images are gif's or lobby the jasper developers to provide and api which exposes the image types.
  • The sample assumes that your report uses and JDBC datasource (sample uses MSSQL).

Source TOC#

ByteArrayDataSource.java(info)

DBServer.java(info)

JasperHTMLReport.java(info)

JasperPDFReport.java(info)

JasperReport.java(info)

SendMail.java(info)

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
java
ByteArrayDataSource.java 1.7 kB 1 12-Dec-2003 01:07 Ebu
java
DBServer.java 1.6 kB 1 12-Dec-2003 01:07 Ebu
java
JasperHTMLReport.java 2.7 kB 1 12-Dec-2003 01:07 Ebu
java
JasperPDFReport.java 1.5 kB 11 25-Apr-2012 04:14 206.190.87.194 Re-uploading the original file.
java
JasperReport.java 4.6 kB 3 29-May-2005 20:56 82.216.174.161
java
SendMail.java 7.1 kB 1 12-Dec-2003 01:07 Ebu
« This page (revision-11) was last changed on 08-Jul-2005 23:06 by 82.216.174.161