Let’s Send an Email Automatically in the Middle of a Workflow (Mail body chapter)

Previous Post: Basic chapter

Change the body of an email using Embedded Commands

In the Basic chapter we created a Workflow App that used 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 the email, attachments, etc. at the [Confirmation] Task. In addition, the template of the text will be configured further.

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

By combining these settings effectively you can create emails with a wide variety of contents. Let’s look into each function. Please open the editing screen 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 [Confirmation] Task

First, please set the Title Data Item as Editable at the [Confirmation] Task. The Data editing permission settings can be changed in the settings window of the [Confirmation] Task.

You can now enter a Title in the input form of the [Confirmation] Task. You just have to embed the Title Data Item in the template emails that will be created by the Throwing Message Intermediate Event (Email). Please open the settings window of the Throwing Message Intermediate Event(Email).

Click the “Insert reference” icon to the right of the Subject field. When Title is selected a character string for data embedding is set. The content of the Title Data Item is set in the Subject line of the email to be sent.

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

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

Let’s configure the App so that text entered in the [Confirmation] Task is 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 [Confirmation] Task. Change each settings item as in the following example.

Item nameBody
Field nameq_string0
Data typeString, Multiple lines
Data editing permissionConfirmation task: editable

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

Embedding procedure is the same as for the Title

The numeric part of the referenced Data Item (for example, the “0” in q_string0) may be different depending on the 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: #{#q_string0}“, 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 [Confirmation] Task

Although it was a String-type Data Item that was embedded above, embedding a 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 nameAttachments
Field nameq_file1
Maximum value of total file size5MB
DescriptionMaximum total file size: 5MB
Data editing permissionConfirmation task: editable

Since the size of emails sent by Questetra BPM Suite must be within 10MB, I set the limit for the total size of attachments to 5MB.

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

Embedding procedure is the same as for the Title

By embedding the File-Type Data Item, the file uploaded at the [Confirmation] Task will be attached to the email. The name of the attachment is embedded in the #{#q_file1}  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 body text

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

The App Name item is a preset, so it can be selected immediately

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.

Combine data to create a URL

Please enter “${var[applicationRoot]}OR/ProcessInstance/listView?processInstanceId=#{processInstanceId} as you see in the screenshot above. If you select “System Variable: Application Root URL”, the string of “${var[applicationRoot]}” is embedded. In the case of “Process ID”,“#{processInstanceId}”is embedded. However, you have to fill in the middle part “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 selecting from the reference menu.

The Process Start User item is also preset, so just select it


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 Start<Workflow.

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

Is the content you entered reflected? Also, check whether the Process Detail page URL is correct. If you don’t have any issues then the instructions for this chapter are complete. You have become able to do some practical settings.

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

Next is the Address embed chapter 


Appendix: Embedding Other Types of Data Item

In this article, a Data Items 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 data types than those introduced in this page.

%d bloggers like this: