Sending an email with attachment from Oracle BPEL

In my previous post I described how to create a PDF file/report in Oracle BPEL (Create a JasperReport from Oracle BPEL).

Now I will describe how to sent this PDF file as attachment in an email.

image1

 

After invoking the createBookService the outcome is used to construct the email message. In particular the filename and the Base64 encoded report.

image2

Constructing the email

Open de mailBook2Maggie mail task by double clicking on it. The General tab of the email task definition is show.
For this example I used a fixed values for the to, subject and body fields. The from account is left on Default.

image3

The attachment tab show a grid where the attachments can be defined.
Click the green PLUS sign to add an attachment definition.
The default attachment name is “attachment1” and the default mime type is “text/html;”.
This screen actually has a bit strange behavior. The created report is not of the “text/html;” type.
Changing this value via this user interface could result in a very annoying exercise.

image4

I have chosen to leave the defaults here and change the values in a different way. Close the email task definition screen by clicking OK.

Open the mail task by selecting the PLUS sign.

image5

The mail task consist of the assignment of the email setting and the invocation of the email service.
The assignment activity can also be used to change the mailservice payload. Lets start doing this. Double click on it to open.

image6

As shown in the screenshot, the email has a multipart content body.

This first part contains the email body and an indication of the body mime type.
The second part contains the report in the body, the mime type of the report and the name of the report.

This post ends with an example of how a received email looks in Maggies email box.

image7

Advertisements

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