FP_SMTP_SET_MODE

Set SMTP transfer mode

This FP instruction configures the transmission settings for event-triggered e-mails. Use this instruction together with the instructions FP_SMTP_CONNECTION to make the SMTP server settings and FP_SMTP_SET_GROUP to specify the destination group.

Parameters

Input

nTransferID (WORD, INT, UINT)

Set the transfer setting ID.

Values: 0–15 (values must be entered in ascending order)

sTrigger (STRING)

Set the trigger type with one of the following keyword settings:

  • 'TRIG=BITON,xxx': Sends an e-mail at the rising edge of the specified bit.

    Values:X, Y, R, L, SR, E, DT.n, LD.n, SD.n

    Example:'TRIG=BITON,R100' sends an e-mail at the rising edge of R100.

  • 'TRIG=TIME,xxxx,yyyy': Sends an e-mail on the specified day and/or at the specified time.

    Values:

    \min,ss (every minute, set time in seconds)

    \hour,mm:ss (every hour, set time in minutes and seconds)

    \day,hh:mm:ss (every day, set time in hours, minutes, and seconds)

    \mon,DD:hh:mm:ss (every month, set date as day, hours, minutes, and seconds)

    \year,MM:DD:hh:mm:ss (every year, set date as month, day, hours, minutes, and seconds)

    \week,hh:mm:ss-w (every week, set day and time as hours, minutes, seconds, and day of week)

    ss=seconds (0–59), mm=minutes (0–59), hh=hours (0–23), DD=day (1–31), MM=month (1–12), w=day of week (0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday)

    Examples:
    1. Every day at 13:30: 'TIME,/day,13:30:00'

    2. Every year on April 1st at 9:00: 'TIME,/year,4:1:9:0:0'

    3. Every week on Friday at 23:50: 'TIME,/week,23:50:00-5'

  • 'TRIG=CYCLIC,xxxx': Sends an e-mail in regular intervals.

    Values:

    30SEC (30 seconds)

    1MIN, 2MIN, 3MIN, 4MIN, 5MIN, 6MIN, 10MIN, 15MIN, 30MIN (minutes)

    1HOUR, 2HOUR, 3HOUR, 4HOUR, 6HOUR, 12HOUR, 24HOUR (hours)

    The shortest cycle is 30 seconds. You can set only one cycle time (values such as '1MIN30SEC' cannot be set).

    Example:'TRIG=CYCLIC,30SEC' sends an e-mail every 30 seconds.

  • 'TRIG=PROGRAM': Sends an e-mail when the instruction FP_SMTP_TRANSFER_REQUEST is executed.

  • TRIG=STATUS,xxx1,xxx2,xxx3: Sends an e-mail when one of the specified PLC status changes occurs.

    Values:

    PROG>RUN (when switching from PROG to RUN)

    RUN>PROG (when switching from RUN to PROG)

    ERR>STOP (when a self-diagnostic error occurs and operation stops)

    ERR>RUN (when a self-diagnostic error occurs and operation continues)

    ERRCLR (when an error is cleared)

    Examples:
    1. When the PLC status changes from PROG to RUN: 'TRIG=STATUS,PROG>RUN'

    2. When one of the following conditions is met: a self-diagnostic error occurs or when an error is cleared: 'TRIG=STATUS,ERR>STOP,ERR>RUN,ERRCLR'

sGroupNumber_Subject

Set the destination group number and the subject of the e-mail.

  • Set up to eight destination group numbers with the keyword syntax 'GRPNO=n1+n2+…+n8'.

    Values: 0–7

  • Set the subject with one of the two following keyword settings:

    • 'SUBJECT=xxxxxx': Sets a user-defined subject text.

    • 'SUBJECTAUTO': Automatically generated subject containing information about the sending trigger type.

      Automatically generated subjects:

      Japanese

      English

      ビットON 検出(R100)

      Bit ON detect (R100)

      一定周期メール(1分毎)

      Interval mail (1 minute)

      一定周期メール(24 時間毎)

      Interval mail (24 hour)

      指定時刻メール(毎分・0 秒)

      Specified time (every minute 0s)

      指定時刻メール(毎時・0 分0 秒)

      Specified time (every hour 0m0s)

      指定時刻メール(毎日・17 時30 分0 秒)

      Specified time (every day 17h30m0s)

      指定時刻メール(毎週・金曜・17 時30 分0 秒)

      Specified time (every Friday 17h30m00s)

      PLC 状態変化(電源ON)

      PLC status change (power on)

      PLC 状態変化(PROG>RUN スイッチ切り替え)

      PLC status change (PROG > RUN)

      PLC 状態変化(RUN>PROG スイッチ切り替え)

      PLC status change (RUN > PROG)

      PLC 状態変化(演算停止自己診断エラー検知)

      PLC status change (operation stop error)

      PLC 状態変化(演算継続自己診断エラー検知)

      PLC status change (operation continuous error)

      PLC 状態変化(エラー解除)

      PLC status change (error release)

      SMTPcREQ 命令による

      SMRPcREQ command

    Note:

    • The language used for automatically generated information is specified with the instruction FP_SMTP_SET_CONNECTION. Use the parameter sCommunication to switch the language from Japanese (default) to English.

    • If multiple PLC status changes have been specified as trigger type, the subject will contain the actual status change that triggered the sending of the e-mail.

    • The keywords 'GRPNO' and 'SUBJECT' must be separated by commas and entered in this order.

Examples:
  1. Destination group number 0, user-defined subject "Time notification e-mail": 'GRPNO=0,SUBJECT=Time Notification E-Mail'

  2. Destination group numbers 1, 3, 4, 7, user-defined subject "Cyclic notification e-mail": 'GRPNO=1+3+4+7,SUBJECT=Cyclic notification e-mail'

  3. Destination group numbers 0 to 7, automatically generated subject: 'GRPNO=0+1+2+3+4+5+6+7,SUBJECTAUTO'

sBodyText (STRING)

Specify a variable containing the text of the e-mail or a character string.

Max string length: 4096 one-byte characters for CPUs version 4.1 or later and version 3.4 to 3.x.

256 one-byte characters for all other versions.

sAttachment (STRING)

Specify whether or not to send additional information or a file attachment.

Include additional information in the e-mail text with one of the following keyword settings:

  • 'INFO=NON': Do not add any information automatically

  • 'INFO=ADD': Add event information (which event has triggered the e-mail)

The following information is added to the e-mail text:

Japanese

English

基本項目

  • 送信元
  • CPU 型番
  • IPv4 アドレス
  • IPv6 アドレス

Basic information

  • From

  • CPU Part number (e.g. CPS41E)

  • IPv4 address

  • IPv6 address

トリガ種類

Detailed information

ビットON 検出(R100)

Bit ON detect (R100)

一定周期メール(1分毎)

Interval mail (1 minute)

一定周期メール(24 時間毎)

Interval mail (24 hour)

指定時刻メール(毎分・0 秒)

Specified time (every minute 0s)

指定時刻メール(毎時・0 分0 秒)

Specified time (every hour 0m0s)

指定時刻メール(毎日・17 時30 分0 秒)

Specified time (every day 17h30m0s)

指定時刻メール(毎週・金曜・17 時30 分0 秒)

Specified time (every Friday 17h30m00s)

PLC 状態変化(電源ON)

PLC status change (power on)

PLC 状態変化(PROG>RUN スイッチ切り替え)

PLC status change (PROG > RUN)

PLC 状態変化(RUN>PROG スイッチ切り替え)

PLC status change (RUN > PROG)

PLC 状態変化(演算停止自己診断エラー検知)

PLC status change (operation stop error)

PLC 状態変化(演算継続自己診断エラー検知)

PLC status change (operation continuous error)

PLC 状態変化(エラー解除)

PLC status change (error release)

SMTPcREQ 命令による

SMRPcREQ command

Note:

  • The address information depends on whether an IPv4 or IPv6 address has been specified by FP_SMTP_SET_CONNECTION.

  • The language used for automatically generated information is specified with the instruction FP_SMTP_SET_CONNECTION. Use the parameter sCommunication to switch the language from Japanese (default) to English.

Include data and/or file attachments with one of the following keyword settings:

  • 'ATT=NONE': Do not add any data to the e-mail.

  • 'ATT=DATA,xxxxxxx': Add data from memory area to the e-mail text.

    The following information is added to the e-mail text:

    Information added to e-mail text (Japanese)

    Information added to e-mail text (English)

    デバイス取得項目

    • デバイス取得(例:DT100)
    • データ数(例:4 デバイス)
    • 変換方法
    • 数値,数値,数値,数値

    Device get information

    • Device number (e.g. DT100)

    • Number of data(e.g. 4 registers)

    • Conversion method

    • <Numerical value1>, <Numerical value2>, <Numerical value3>, <Numerical value4>

    Specify the start address, the number of data transferred, the conversion method, and the line feed position.

    Values:

    Memory area and start address: WX, WY, WR, WL, DT, LD, SD

    Number of data transferred: 1–1000

    Conversion method:

    • BIN1w (unconverted 16-bit binary, cannot be used to add data to e-mail texts, use the 'FILE' keyword instead)

    • US (16-bit unsigned decimal)

    • SS (16-bit signed decimal)

    • UL (32-bit unsigned decimal)

    • SL (32-bit signed decimal)

    • SF (32-bit single-precision floating point)

    • DF (64-bit double-precision floating point)

    • HEX1w (16-bit HEX)

    • HEX2w (32-bit HEX)

    • HEX4w (64-bit HEX)

    • ASCII (ASCII character, output is enclosed in "")

    Line feed position: 0–255.

    • 0: output line feed at the end of the file only.

    • n: output line feed after every n data points.

  • 'ATT=DATA,xxxxxxxxxxx,FILE=yyyyyyyyyyy': Add data from memory area to the e-mail text and additionally attach the data as a file. Use the same values as for 'ATT=DATA,xxxxxxx'.

  • 'ATT=FILE,Filename': Attach a file from a specified folder on the SD card.

    Use the keywords 'TOP' and 'END' to automatically add date and time to the file name (yymmdd_hhmmss).

    TOP: Add data at the beginning of the file name

    END: Add data at the end of the file name

Note:

  • The language used for automatically generated information is specified with the instruction FP_SMTP_SET_CONNECTION. Use the parameter sCommunication to switch the language from Japanese (default) to English.

  • It is not possible to specify LOG folder names for file attachments ('\LOG0' to '\LOG15').

  • To generate the sAttachment string you can also use FP_SMTP_GET_DATA_FORMAT.

Examples:
  1. Do not add any information or data automatically: 'INFO=NON,ATT=NONE'

  2. Automatically add information, do not add data: 'INFO=ADD,ATT=NONE'

  3. Do not automatically add information, but add 16-bit hex data from DT100 to DT109 to the e-mail text: 'INFO=NON,ATT=DATA,DT100,10,HEX1w'

  4. Do not automatically add information, but attach a file from the SD card: 'INFO=NON,ATT=FIL,\Folder\FileName.bin'

Output

bError (BOOL)
Turns to TRUE under the following conditions:
  • if a timeout of the connection is exceeded

  • if an IP address is invalid

When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Remarks

  • The number of characters for string data should not exceed 4096 for CPU units Ver.3.4 to Ver.3.x and Ver.4.1 or later, and 256 for other CPU units.

  • This instruction is not available in interrupt programs.

  • Upper and lower case characters can be used for operands for which a character constant can be specified. "Abcd", "ABCD" and "abcd" are synonymous, however, file names are case-sensitive.

  • Before you execute the instruction, you need to specify the e-mail transmission server using FP_SMTP_SET_CONNECTION or the setting dialog of the SMTP client.

  • Before you execute the instruction, you need to specify the group and event e-mail settings using FP_SMTP_SET_GROUP or the setting dialog of the SMTP client.

  • Before you execute the instruction, make sure that sys_bIsEthernetInitializing is FALSE. sys_bIsEthernetInitializing turns to TRUE when the instruction is executed. When you execute the instruction while sys_bIsEthernetInitializing is TRUE, an error occurs.

  • The instruction can only be executed when the transfer request flag for the specified transfer setting or the specified nLogID number is FALSE. When the transfer request flag is TRUE, an operation error occurs.

  • When this instruction has been executed successfully, the system variables sys_bIsCarry and sys_iEthernetConnectionErrorCode are reset.

  • When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if a value specified for a parameter is outside the permissible range.

  • if transfer IDs are not specified in ascending order.

  • if the instruction is executed in an interrupt program

  • if an e-mail transmission server that has not been specified with the instruction FP_SMTP_SET_CONNECTION or the setting dialog of the SMTP client is specified.

  • if the same destination group number is specified redundantly.

  • if a destination group number that has not been defined with the instruction FP_SMTP_SET_GROUP or the setting dialog of the SMTP client is specified.

  • if the e-mail transmission request flag for the specified transfer setting is "TRUE: Transfer requested".

  • if the transfer request flag for a specified nLogID number is TRUE, e.g. if sys_blsLog0DataRecordingActive is TRUE.

  • if the number of characters for string data exceeds its upper limit. The upper limit is 4096 characters for CPU units Ver.3.4 to Ver.3.x and Ver.4.1 or later, and 256 characters for other CPU units.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if a value specified for a parameter is outside the permissible range.

  • if transfer IDs are not specified in ascending order.

  • if the instruction is executed in an interrupt program

  • if an e-mail transmission server that has not been specified with the instruction FP_SMTP_SET_CONNECTION or the setting dialog of the SMTP client is specified.

  • if the same destination group number is specified redundantly.

  • if a destination group number that has not been defined with the instruction FP_SMTP_SET_GROUP or the setting dialog of the SMTP client is specified.

  • if the e-mail transmission request flag for the specified transfer setting is "TRUE: Transfer requested".

  • if the transfer request flag for a specified nLogID number is TRUE, e.g. if sys_blsLog0DataRecordingActive is TRUE.

  • if the number of characters for string data exceeds its upper limit. The upper limit is 4096 characters for CPU units Ver.3.4 to Ver.3.x and Ver.4.1 or later, and 256 characters for other CPU units.

sys_bIsCarry (turns to TRUE for one scan)
  • if the instruction is executed during the initialization of Ethernet, sys_iEthernetConnectionErrorCode is set to "11: Ethernet is being initialized".

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bSetModePlcData: BOOL:=FALSE;
		bSetModePlcDataError: BOOL:=FALSE;
		arRealArray: ARRAY [0..15] OF REAL:=[16(0.0)];
		iID10: INT:=10;
	END_VAR

POU body

If bSetModePLCData changes from FALSE to TRUE and sys_bIsEthernetInitializing is FALSE, the instruction is carried out.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_COMMENT,, ^Set mode to attach File located on SD card of FP7 PLC,4,1,34,4,);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 10 ;
        NETWORK_BODY
B(B_VARIN,,iID8,32,2,34,4,);
B(B_CONTACT,,bSetMode,4,1,6,3,R);
B(B_VAROUT,,bError,47,2,49,4,);
B(B_VARIN,,'GRPNO=0~SUBJECT=Time Notify Mail',32,4,34,6,);
B(B_VARIN,,'Hello~ this is time notify Mail from system. See attachment',32,5,34,7,);
B(B_VARIN,,'TRIG=TIME~/day~13:30:00',32,3,34,5,);
B(B_CONTACT,,sys_bIsEthernetInitializing,13,1,15,3,N);
B(B_VARIN,,'INFO=ADD~ATT=FILE;FILE=',26,7,28,9,);
B(B_VARIN,,sFilename,26,8,28,10,);
B(B_F,CONCAT-2!,,28,7,34,10,,?D?D?C);
B(B_F,FP_SMTP_SET_MODE!,,34,0,47,8,,?DEN?DnTransferID?DsTrigger?DsGroupNumber_Subject?DsBodyText?DsAttachment?AENO?CbError);
L(1,2,4,2);
L(34,7,34,8);
L(15,2,34,2);
L(6,2,13,2);
L(1,0,1,10);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If DF(bSetMode) AND NOT sys_bIsEthernetInitializing then
    FP_SMTP_SET_MODE(nTransferID := iID8,
                     sTrigger := 'TRIG=TIME,/day,13:30:00',
                     sGroupNumber_Subject := 'GRPNO=0,SUBJECT=Time Notify Mail', 
                     sBodyText := 'Hello, this is time notify Mail from system. See attachment',
                     sAttachment := CONCAT('INFO=ADD,ATT=FILE;FILE=', sFilename),
                     bError => bError);
End_if;

Modified on: 2024-03-07Feedback on this pagePanasonic hotline