This post applies to WSO2 Business Process Server 3.5.1
From the past couple of posts, I have explained how we can create a simple BPMN workflow and use the WSO2 Business Process Server to deploy and test that. From this post, Im going to explain how we can send an Email from Business Process Server as a part of a workflow activity.
As an example, we are going to extend the same workflow that was created in the earlier posts. We will add a email sending task and also explore how we can get information that was sent as the inputs for the workflow.
1. Lets change our workflow inputs and add email address as an input parameter.
Now our workflow is having 4 input parameters.
2. To send an email, we have to add a "MailTask" for the workflow. Lets add that after the Human Task of our workflow. The final workflow should look like the following.
3. Lets configure the mail task to send emails to the email address given in the input parameters to the workflow. We can use the inbuilt variables to do this. Any input parameter(or a result from another task) can be accessed through the rest of the flow by giving the ID parameter in a special notation such as the following.
For Ex: To access the email variable, the following notation should be used.
Lets configure the "MailTask" parameters. I have configured the parameters in the following way.
To :
From the past couple of posts, I have explained how we can create a simple BPMN workflow and use the WSO2 Business Process Server to deploy and test that. From this post, Im going to explain how we can send an Email from Business Process Server as a part of a workflow activity.
As an example, we are going to extend the same workflow that was created in the earlier posts. We will add a email sending task and also explore how we can get information that was sent as the inputs for the workflow.
1. Lets change our workflow inputs and add email address as an input parameter.
Now our workflow is having 4 input parameters.
2. To send an email, we have to add a "MailTask" for the workflow. Lets add that after the Human Task of our workflow. The final workflow should look like the following.
3. Lets configure the mail task to send emails to the email address given in the input parameters to the workflow. We can use the inbuilt variables to do this. Any input parameter(or a result from another task) can be accessed through the rest of the flow by giving the ID parameter in a special notation such as the following.
${variable_name}
For Ex: To access the email variable, the following notation should be used.
${email}Also you can access these variables in conjunction with other constant string values. Therefore we can create more informative email subjects and content.
Note :The "email" is the Id we have given for that field at the start event.
Lets configure the "MailTask" parameters. I have configured the parameters in the following way.
To :
${email}From :
noreply@order.sample.com
Subject :
Thank you for placing an order from usNon html :
Dear ${userId},
Thank you for placing your order with us.
We have ${action} your order items of ${orderItem}.
Thanks,
Order.Sample
Note:
The above ${action} is not an input parameter for the workflow but it is the response from the Human Task of the workflow.
The final configuration of the "Mail Task" should look like the following.
4. The workflow is complete. Lets create a deployment artifact and deploy that in the WSO2 Business Process Server.
Note:
If you are using the same WSO2 Business Process Server to try out this sample, please undeploy the earlier added process and add the new one.
5. Configure the Business Process Server with the mail server we want to use. To configure the mail server, we have to edit the repository/conf/activiti.xml file that is located in the Business Process Server distribution(<CARBON_HOME/repository/conf/activiti.xml>).
We have to add the following properties to the activiti.xml to configure the mail server.
<property name="mailServerHost" value="smtp.gmail.com"/>
<property name="mailServerPort" value="456"/>
<property name="mailServerDefaultFrom" value="mailtask@gmail.com"/>
<property name="mailServerUseSSL" value="true"/>
<property name="mailServerUsername" value="mailtask@gmail.com"/>
<property name="mailServerPassword" value="mailtask123"/>
Once the properties have been configured, the activiti.xml should look like the following.
Then you have to copy the following jar files into the <BPS_HOME>/repository/components/lib directory and restart the server.
- org.apache.commons:commons-email:jar:1.3
- javax.mail:mail:jar:1.4.7
- javax.activation:activation:jar:1.1
6. Lets invoke the BPMN process and tryout the email sending scenario. We can use the BPMN Explorer as we did in the earlier posts.
Once we tried to start the workflow from the BPMN Explorer, you should now see the additional parameter - email address as an input parameter.
Please note that you have to complete the Human Task in-order to get the email as we have the Human Task before the Mail Task
You should get an email as shown below to the given email address as the input of the workflow.
As you can see, the variables that we defined in the email template have been replaced by the input values we have given.
Reference by ${var_name} not work in EI 6.1 ... :( any other idea how to make it working?
ReplyDeleteI can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. find social media links
ReplyDeletefirst rate article, it is especially useful! I quietly started out in this, and i am turning into more acquainted alongside inside the center of it better! Delights, statement war more and toting going on outstanding! Buy Email List
ReplyDeleteHow to develop your income by building trust and respect with your personal business opportunity leads. It will never happen overnight. Just follow some basic rules and your income will grow at a nice steady rate.
ReplyDeleteI am really happy to say it’s an interesting post to read about Process serving New Jersey. I learn new information from your article , you are doing a great job .
ReplyDeleteThanks for this. I really like what you've posted here and wish you the best of luck with this blog and thanks for sharing. BPMN
ReplyDeleteThanks for sharing this information. It’s a very helpful and nice information about Process serving New Jersey. I’m would be awaiting your next post.
ReplyDeleteNice Information.But how to send an attachment with send mail Task?
ReplyDeleteInteresting information and nice article,
ReplyDeleteProcess serving New Jersey