Attaching a Birt Report as an Email Attachment

Update:

Please have a look at a complete solution from Daniel:
http://www.xcentricway.ca/tutorial01.htm

Hi,

This is a very specific situation in which you might want to attach the output of a Birt report and send to some users or send it as part of communication log.

Lets say you want to send the Workorders Detail report to some user and that is triggered by a “Select Action”.

Create your signature option give all required rights to the user group.

So, if you created a signature option by name “sendrepbyemail”, create a method by that name in your AppBean class:

public int SENDREPBYEMAIL() throws MXException, RemoteException

In this method you will perform the following steps:

  1. Execute the report and generate a PDF file out of it:

//Generate the Birt Report

 

ReportAdminServiceRemote  birtAdmService = (ReportAdminServiceRemote)MXServer.getMXServer().lookup(“BIRTREPORT”);
byte[] abyte0 = birtAdmService .runReport(userInfo, reportName, appName, parameterData, filename, “pdf”);

Once you have the generated in bytes, just write to a temporary location:

FileOutputStream fileoutputstream = new FileOutputStream(“FILE_IN_TEMPPATH”);
fileoutputstream.write(abyte0);
fileoutputstream.flush();
fileoutputstream.close();

2. Send the generated PDF as an attachment:

String fileNames[] = {filePath};
MXServer.sendEMail(toAddr, ccAddr, bccAddr, fromAddr, subject, body, replyToAddr, fileNames, null);

Thats it, its all set and the end user will get a nice email (if the email content is nice) with the report attached as a pdf document.

Regards,

Admin

Advertisements

15 thoughts on “Attaching a Birt Report as an Email Attachment

  1. Kuldeep

    Hi there, Thnx for nice article on attaching birt reports as email attachment.

    How can we invoke/attach ACTUATE reports in similar way?

    Reply
  2. admin Post author

    As per the above code I get the “BIRTREPORT” service. Can you lookup a similar service for Actuate?

    And the find the similar reportadmin class and I should work. I do not have actuate setup in my maximo currently so I cannot give you the exact classes.

    Try the above suggestion and if it still does not resolve let me know and I will try myself.

    Regards,

    Reply
  3. Pingback: Using Commtemplate to send out email in custom Java Code | Maximo Technical Blog

  4. Michael Angelo

    Hi! I’m using Maximo 6.2.x and Actuate 8. Do you have a similar solution for Actuate? I plan to apply this on workflow assignments.

    Thanks in advance.

    Reply
    1. Latif

      Hi,
      Can you please share ur rptdesign with us.
      actually i want send one pdf to multiple user from Eclipse BIRT or maximo automatic.

      Means i will show email id on the report top & PDF auromatic send to that onlr email id.

      Thanks in advance

      Reply
    2. Latif

      Hi,
      Can you please share ur rptdesign with us.
      actually i want send one pdf to multiple user from Eclipse BIRT or maximo automatic.

      Means i will show email id on the report top & PDF auromatic send to that onlr email id.

      Thanks in advance

      Reply
  5. Daniel Ng

    Hi,

    Thanks for the article. I’ve to implement something similar and your article certainly pointed me to the right direction. Your contribution is very much appreciated! In return, I am sharing my complete solution as well. My solution basically packaged up what you discussed here with a custom dialog box and a custom AppBean class. It goes into great detail on each steps along the way and it is meant for newbies.

    My tutorial can be found in this link for those who are interested:
    http://www.xcentricway.ca/tutorial01.htm

    Thanks,
    Daniel Ng

    Reply
    1. admin Post author

      Hi Daniel,

      I really liked the detailed description you have put on your blog. It must have been a lot of effort but I am sure anybody who reads will appreciate it.

      Thanks

      Reply
  6. Latif

    Hi,
    Can you please share ur rptdesign with us.
    actually i want send one pdf to multiple user from Eclipse BIRT or maximo automatic.

    Means i will show email id on the report top & PDF auromatic send to that onlr email id.

    Thanks in advance

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s