Part 2 - Send emails from Oracle BPM using Mail Activity - Implement Mail Activity in BPM

Before going ahead with this implementation, please ensure you have completed the EM Configuration. This can be completed by following Part 1 of this blog post:
Part 1 - Send emails from Oracle BPM using Mail Activity - Weblogic EM Configuration

Implement a send Mail activity within a BPM Process in JDeveloper BPM Studio

In a BPM Process there is quite often the requirement to send an email to user(s) to keep them updated or to make them aware of an event that has taken place. It is actually straight forward to achieve this.

We will use a very simple BPM process to illustrate:

1. Firstly, we will create a Data Object to store the entire output payload of the worked human task called Task_DO of type TaskExecutionData:

2. Next, select the Mail Activity from the Notification components:

And drag it into the BPM Process:

3.  In the General tab, we populate 2 fields. 
     - Enter Default into the From Account field, this will be obtained from your configuration in EM.
     - Enter the Email address you want to send an email to in the To field. This can also be extracted from a Data Object via XPath. To send to multiple emails, separate each email address with a semi colon (;)

4. In the Content tab, you populate the Subject and Body of the email. This can be made up of static text or from expressions as shown below:
For reference, the expression in the Body is: concat('Task Number ', bpmn:getDataObject('Task_DO')/ns:systemAttributes/ns:taskNumber, ' has been worked by ', bpmn:getDataObject('Task_DO')/ns:systemAttributes/ns:updatedBy/ns:displayName, ' with an outcome of ', bpmn:getDataObject('UserTask_outcome'))

5. We can also add attachments to the mail via the Attachments tab. The value must map to an element of type base64Binary, which holds the document in a binary format. The Mime Type must reflect the type of stored document too.

If you navigate back to your Composite, you will see a new external reference created to a Notification Service Web Service. The WSDL referenced is NotificationService.wsdl and is stored in MDS so you do not have to worry about maintaining it:

6. Now, your implementation from a development perspective is complete. Let's see the project in action.

Deploy the BPM project to your Weblogic SOA server.

7. Create an instance for the deployed BPM Project via EM:

8. Work the running instance of the Human Task:

9. Check the BPM Flow to confirm a successful flow.

10. Check your Email Inbox for the Email address you entered. Voila!

11. You can also monitor the status of instances of the Email User Messaging Driver from the EM:

No comments:

Post a Comment