Send the tag value in the email body

<< Click to Display Table of Contents >>

Manual > Monitoring system construction guide > Building server logic > Sending email >

Send the tag value in the email body

overview

Here we will explain a sample of how to send an email by embedding the tag value in the body of the email.

 

Actions used: Send mail action/Tag report action

 

In this example, when M0000 of the PLC device turns ON, an email message will be created based on the value of each tag, and the message will be attached and sent.

The Tag report action is used to create the email text.

 

 

c_action_0372

 

 

 

Overview of email writing

 

Prepare the source file (pre-conversion file) for the email text in advance and specify it as the pre-conversion file for the Tag report action. When the calling Tag event generates a trigger, it will convert the pre-conversion file according to its format and output it as an email document file. The Send mail action will then be executed and the email will be sent with the email document file as an attachment.

 

The format of the email text used in this sample is as follows:

 

Pre-conversion file (mail.txt)

[DATE]

Error code: [ERRCODE]

Message: [ERRMSG]

Device code: [DEVICE]

Temperature: [TEMP]

Pressure: [PRES]

 

 

Converted email text file (yourmail.txt)

2003/01/01 00:00:00

Error code: 0

Message: Normal

Device code: 3918

Temperature: 6959

Pressure: 1391

 

 

 

Download the sample

There are two samples provided in the example shown on this page.

 

The sample can be downloaded from below.

 

■ A sample of updating an attachment by Tag report and Send mail (sample02)

 

■ A sample of updating and sending the email body using Tag report (sample03)

 

 

Operation check

Load the sample server configuration file from FA-Server and bring the application online (yellow arrow).

 

After going online, set U01.F01.ALARM to TRUE.

 

After checking that the number of times the action was executed is incremented as shown below, please confirm that the email was sent correctly.

 

c_action_0175

 

 

Setup Procedure

Tag configuration

 

1.Prepare tags for creating email text. Please register the following tags here.

 

Tag Name

Mark string

the purpose

U01.F01.ERRCODE

[ERRCODE]

Error Codes

U01.F01.ERRMSG

[ERRMSG]

message

U01.F01.DEVICE

[DEVICE]

Equipment Code

U01.F01.TEMP

[TEMP]

temperature

U01.F01.PRES

[PRES]

pressure

U01.F01.ALARM

---

Alarm tag (M0000)

U02.F01. DATE

[DATE]

Time character tag "%Y/%m/%d %H:%M:%S"

 

Of the above, "U01" uses a virtual device unit, and "U02" uses a memory device unit. The time character tag of the memory device is used as the occurrence date and time to be included in the email text.

 

 


Action Settings

 

1.Tag reportRegister action "A01".

 

Set the Tag report pre-conversion and post-conversion files as follows.

 

c_action_0373

 

Create a text file with the following content as the pre-conversion file.
 

Pre-conversion file (mail.txt)

 

[DATE]

Error code: [ERRCODE]

Message: [ERRMSG]

Device code: [DEVICE]

Temperature: [TEMP]

Pressure: [PRES]

 

 

Add a field to the Tag report action and map each mark string to a tag.
 
c_action_0170

 

(Example of R01)
c_action_0171
 

 

2.Register the Send mail action "A02".

 

c_action_0172
 

In the sample, the above are tentative settings.

 

Please configure the sending mail server, port number, account name, password, authentication method, etc. according to the specifications of the mail server you are connecting to.

 

3.In the Transmission Content tab, set the destination, etc.
 

c_action_0173

 

Please specify "CFG\yourmail.txt" as the attachment to notify of the alarm status.

 

Please set other settings such as the destination email address appropriately according to your environment.

 

 

hint

In the message file settings above, replace "text.txt" with "yourmail.txt" and change the attachment setting to blank to modify the file so that it replaces the body of the email rather than sending it as an attachment (the version with this modification is "sample03" introduced in the "Sample Download" section on this page).

 

c_action_0176

 

 

hint

You can also attach images to the attachments of the Send mail action. For example, you can capture a screen image when an error occurs and output it as a JPEG file using the screenshot action, and send that image as an attachment.

 

 

 


Event Settings

 

1.Create Tag event.

 

In this example, we will set the event to occur when U01.F01.ALARM becomes TRUE.

 

c_action_0374

 

Register the execution actions in the following order: "A01" (Tag report) and then "A02" (Send mail).

 

c_action_0375