In QuickHMI, you have the option of having automatic e-mails sent when, for example, variable values change, alarms are triggered or control elements are interacted with.
To create or edit e-mail templates, select the menu item
“E-mail templates” in the Project Explorer.
Click on the plus icon to create a new e-mail (e-mail template). The Email template window appears:

Start by giving the email a name under “General” or connection data and defining the“Decay time“. You can find out more about this further down in the article under the heading “Decay time (s)“.
Then enter the login data for the SMTP server from which the e-mail is to be sent.

Under “Message” you then formulate the actual message with a subject. At least one subject is required to send an e-mail.
If you wish to format the text (e.g. bold, italics, color, etc.), you can do this by activating HTML via a checkbox.
You can then format the text by writing HMTL tags. It is important to note that if HTML is deactivated, the tags must also be removed again, as they will otherwise be written out as plain text.
If HTML is activated, no “normal” line breaks are recognized via ENTER, as is typical for HTML. For a line break, please use the tag “<br/>“.

Then select the addresses under “Addressing” (sender, recipient, CC, BCC). Multiple addresses are separated by a comma.
You can send a test message at any time to check your entries.
Once all the entries have been made, confirm with “Add” to save the e-mail template.
This template can now be used to automatically send an e-mail when certain events occur.
The first step is to specify a corresponding trigger – > a trigger.
An e-mail can be sent when a control element is triggered (e.g. when a button is clicked), when a variable value is changed or when an alarm is triggered.
Cooldown time (s)
With the QuickHMI e-mail function, e-mails are sent automatically as described above. In extreme cases, this would mean that if, for example, a variable changes 20 times a second, 20 emails are also sent per second. To prevent this, a decay time can be set. If“10” is entered here as an example, a maximum of one mail is sent every 10 seconds.
If further mail-triggering events occur within these 10 seconds, the sending of further mails is blocked for this time. However, the information is not lost, but is stored temporarily and either written at the end of the summary in the mail after the cooldown time or added as an attachment (from a size of 5 MB).
You can use the placeholder“@cache” to determine where exactly the information should be placed as a summary within the email. You can find out more about this further down in the article under the heading “Placeholder“.
The decay time is only relevant for mails that are sent automatically. This means when variables are changed and when alarms are triggered. When a control element is triggered by the user, the mail is sent immediately. From this moment on, the cooldown time for automatic mails starts again.
Sending an e-mail for control element events
Select a control element for which you want to send an e-mail when it interacts. In this example, a button is selected.
Add a desired click event to the “Properties” under “Action” and create a new action function.
You can find a description of the actions of control elements in the article “Actions“.
Use the “SEND_EMAIL” command and select the previously saved e-mail template.
“Save” and then close the window.

Now you will receive an e-mail with the content you have defined each time you click on the button.
This is the simplest example of the use of e-mail templates.
Sending an e-mail when a variable value is changed
To have an email sent when a variable value is changed, click on
“Email templates” in the Project Explorer to call up the email template.
Here you select the desired variable under “Trigger” using the button of the same name.


In the“Action assignment” that then opens, select the“OnVariableChanged” event. Then check the box for the variable whose value change is to be responded to by sending an email. Then“save” to continue.
The last step is to“save” the“email template“.
If the value of the selected variable changes, an e-mail is sent with the content you have defined.
By using appropriate placeholders (see article “Placeholders“), information on the changed variable can be added to the mail.
Sending an e-mail when an alarm is triggered
To have an e-mail sent when an alarm status changes, you must assign an e-mail template to the corresponding alarm.
To do this, go to the alarm settings when creating an alarm variable and select the desired template under “E-mail“.
Then click “Save” and “Add” to create the alarm variable. Of course, you can add the e-mail function to an alarm variable that has already been created by editing the variable.
You can find out more about alarm variables in the article “Alarm variables“.


If an alarm is now triggered, an e-mail is sent with the content you have defined.
By using appropriate placeholders (see article “Placeholders“), information about the triggered alarm can be added to the mail.
Placeholder
In QuickHMI, you have the option of using placeholders for the e-mails.
Placeholders are certain commands that read a value or a property, such as a variable, and send this status as information in the e-mail
They ensure that the content of emails is written automatically, depending on the situation. Placeholders can be used both in the subject of an email and in its text.
There are various placeholders that can be used.
They only work if they are written in curly brackets.
Placeholder: @changedvariable
The placeholder “@changedvariable“ is replaced when a variable value is changed, with all the information of the changing variable.
However, this only works if the mail is sent due to a variable change, as described in the article above.
In other cases, this placeholder is not replaced but written out as plain text.


Placeholder: @triggeredalarm
The @triggeredalarm placeholder is replaced by all the alarm information when the status of an alarm changes.
However, this only works if the mail is sent due to the status change of an alarm, as described in the chapter above.
In other cases, this placeholder is not replaced but written out as plain text.


Placeholder: @tag
This placeholder is particularly useful to use in the subject line. It is replaced by a short description of why the email was sent.
This saves you having to enter a new subject each time or prevents the same standard subject from always being used. The subject changes automatically depending on the reason for the mail.


Placeholder for single values
As can be seen in the previous chapters, the placeholders “@changedvariable“ and “@triggeredalarm“ are replaced by entire blocks of information.
It is therefore unfavorable to use these placeholders in a continuous text. To avoid large blocks of information and only read out individual pieces of information from the block, you can add a single value to one of the placeholders described above.
For example, the placeholder “@changedvariable“ is replaced by the information block consisting of “Name“, “Value“, “Quality“, “Message” and “Timestamp“.
It is now possible to read out individual pieces of information from this. For example, if you only want the name and value of the variable, write the following placeholders in the e-mail:
- “@changedvariable.name” and “@changedvariable.value“


Here too, “@changedvariable” placeholders are only replaced if the variable is changed. Otherwise they appear as plain text in the e-mail.
The same principle also applies to “@triggeredalarm” placeholders.
Overview of the individual values for “@changedvariable” placeholders
- @changedvariable.name
- @changedvariable.value
- @changedvariable.quality
- @changedvariable.message
- @changedvariable.timestamp
Overview of the individual values for “@triggeredalarm” placeholders.
- @triggeredalarm.name
- @triggeredalarm.type
- @triggeredalarm.is_active
- @triggeredalarm.message
- @triggeredalarm.begin
- @triggeredalarm.end
Placeholder for displaying variables
By using placeholders, the values of individual variables can also be read out and inserted into the e-mail.
To use a variable as a placeholder, you need the name of the variable as well as the name of the data source to which this variable belongs.
In this example, we want to use the number of currently connected clients in an email.
This value can be found in the system variable “current_session_count“. The data source name of the system data source is “System“.

Not all variables can be used in placeholders. Only global variables can be used for this purpose.
Global variables are:
- Variables from data sources that have been created by the user, i.e. you.
- Internal variablesthat have been created as global.
- The system variables“current_session_count“,“active_alarm_count” and all data sourcestatus variables.
No global variables are:
- All variables of the system data source (with the exception of those mentioned above).
- Internal variables that have been created as local.
Placeholders for variables consist of curly brackets in which an “@” + data source name + variable name is written.
Data source and variable names are separated by a dot. In this case, @System.current_session_count.


The placeholder @System.current_session_count has been replaced by the value of the variable.
Placeholders for variables also work for control element actions as well as for variable changes and triggered alarms.
If you make a mistake or write variables that do not exist, the placeholder is written out as plain text with the addition that the variable was not found.

Placeholder: @cache
This placeholder refers to the option of setting a cooldown time when creating a mail. You can find a more detailed description in the article Decay time (s).
It is replaced by all information that is created during the cooldown period. If this placeholder is missing, the information is written at the end of the mail or added as an attachment (from a size of 5 mb).
