Previous Post: Basic chapter

  • Basic chapter: Sending an email with a fixed mail body to a fixed address
  • Mail body chapter: Changing the mail body of an email using Embedded Commands
  • Address embed chapter: Changing the address of an email using Embedded Commands

Change the body of an email using Embedded Commands

In the “Basic chapter” we created a Workflow App that operates only the basic function of the “Throwing Message Intermediate Event (Email)”. In this chapter you’ll change the App so that you can set the title, the body of an email, attachments, etc. at the [Confirm] Task. In addition, the template of the text will be further configured.

  • Enter a subject at the [Confirm] Task
  • Enter parts of the text in the [Confirm] Task
  • Specify the file to be attached to the email at the [Confirm] Task
  • Insert the App Name that sent the email into the text body
  • Insert the URL of Process Detail Page into the text body
  • Insert the Process Start User’s name in the email

By combining these settings well, you can create emails with a wide variety of contents. Let’s look into each one. Please open the modeler of the “Throwing Message Intermediate Event (Email) test” App which you created in the “Basic chapter”.

Hereafter, I am going to describe each of the 6 settings on the App mentioned above, one after another. We will touch on the result of the settings at the end of the article, but you can also try to save and release the App upon finishing the setup of each one and check how it works.

Enter a Title at the [Confirm] Task

First, please set the Data Item of “Title” as Editable at the [Confirm] Task. The setting of Data editing permission can be changed in the properties of the [Confirm] Task, or go through “Data Item tab > Data editing permission”.

You can now enter a Title in the input form of the [Confirm] Task. You just have to embed a Data Item of “Title” to the template emails that will be created by “Throwing Message Intermediate Event (Email)”. Please open the properties of “Throwing Message Intermediate Event(Email)”. If you select “Title” in the menu “Embedded Command” and click the “Copy to Clipboard” button, the formula for embedding strings is copied to the clipboard. By pasting the string into “Subject”, the content in the Data Item of “Title” will be set as the subject of any email that is sent.

Data Items and Process-specific information can be embedded in an email using this procedure in the properties of “Throwing Message Intermediate Event (Email)”. Please keep that in mind because we will use this procedure frequently in the following contents.

Enter a part of the email body in the [Confirm] Task

Let’s make settings so that text entered in the [Confirm] Task are embedded in the body of an auto-sending email. First of all, please add a “String” type Data Item so that an input field is added to the [Confirm] Task. Change each setting item as in the following example.

Item name Body
Data type String, Multiple lines
Data editing permission Confirm task: editable

Now that you have prepared the Data Items you want to embed to the body, let’s embed the new Data Item in the “Throwing Message Intermediate Event (Email)” Settings using the same procedure as with the “Title”.

The number in the Embedded Command code string that is generated may be different according to your environment, but you don’t have to worry about it. The numeric part is the number of the Data Item, so it can be shifted.

In the case of typing “Message: $ {[Body: 0]}“, for example, if the content of the Body in the Data Item is “Hello”, the text “Message: Hello” will be generated. In this way, you can flexibly change the body of the email by setting the part that you want to rewrite according to each situation using the Embedded Command.

Specify the file to be attached to the email at the [Confirm] Task

Although it was the Data Item of “String” type that was embedded above, embedding the “File” type Data Item enables you to attach files to the email. Please add a “File” type Data Item and set it up as follows.

Item name Attachments
Maximum value of total file size 5MB
Description Maximum total file size: 5MB
Data editing permission Confirm task: editable
Since the size of the email sent by Questetra BPM Suite needs to be within 10MB, I set the limit for the total size of attachments to 5MB.

By setting it as editable in the [Confirm] Task, the file upload field will be indicated on the [Confirmation] Task input form. Please do the embedding setting as follows in the properties of the “Throwing Message Intermediate Event (Email)” as with the “Title”

By embedding the File Type Data Item, the file uploaded at the [Confirm] Task will be attached to the email. The name of the attachment is embedded in the $ {[Attachments: 1]} part of the email body. If you attach multiple files to it, their names will be indicated in a line separated with commas. If you don’t attach any file, nothing will be inserted.

Insert the Name of the App which sent the email into the text body

Embed the App Name in the email body so that its recipient can see by which App the email was sent. The App Name can be embedded without presetting a Data Item.

Insert a URL of the Process Detail Page into the text body

It will be useful if the Process detail page can be opened directly from the email when the recipient of the email wants to know what kind of processing has been done so far and what will follow from now on. Let’s paste the URL of the Process detail page in the text body.

The URL of the Process detail page has the format as “http://example.questetra.net/OR/ProcessInstance/listView?processInstanceId={process id}”. For the part “http://example.questetra.net/” you can embed “System Variable: Application Root URL”. The Process ID can also be embedded, so this URL can be generated dynamically, depending on the App used.

Please enter “${var[applicationRoot]}OR/ProcessInstance/listView?processInstanceId=${[Process ID]}” as you see in the screenshot above. If you select “System Variable: Application Root URL” from the drop -down list, the string of “${var[applicationRoot]}” is indicated to be copied to the clipboard. In the case of “Process ID”,“$ {[Process ID]}”is copied to the clipboard. However,you have to fill in the middle part of “OR/ProcessInstance/listView?ProcessInstanceId=” manually.

Insert Process Start User name into an email

Finally, let’s insert a name into the email. This time, I will insert the name of the Process Start User at the end of the text body. This can also be embedded just by copy and paste.


Now you have finished setting up the App. Let’s save and release it to check its operation. Please Start a Process of the App “Throwing Message Intermediate Event (Email) test” from the list of “Start”<“Workflow”.

There should be three Data Items which you can edit on the Operating screen of the [Confirm] Task; “Title”, “Body”, and “Attachments”. The input form should look like the above figure. Please input something and try clicking on ‘Finish “Confirm”.

Is the content you entered reflected? Also, check whether the Process Detail page URL is correct. If you don’t have any issues the instruction of “Mail body chapter” is over. You have become able to do some practical settings.

In the next “Address embed chapter” I will introduce settings for changing the email address, which is currently fixed, in accordance with the situation.

Next: Address embed chapter (Now preparing)


Appendix: Embedding Other Types of Data Item

In this article, a Data Item of “Title”, “Body (String type)” and “Attachments (File type)” are embedded in an email, but other data types can be embedded as well. I will briefly introduce the result of embedding them here.

If you embed the other Data Items in an email as in the example in the left figure, it will be shown on the email as in the right figure. The embedding method itself is the same as String type and File type. Please refer to that when you want to use other than the Data Types introduced in this page.

1 thought on “Let’s Send an Email Automatically in the Middle of a Workflow (Mail body chapter)”

  1. Pingback: Let’s Send an Email Automatically in the Middle of a Workflow (Basic chapter) – Questetra Support

Comments are closed.