FP_SMTP_SET_MODE_TRANSFER_LOG

Set SMTP transfer mode for data recording files

This FP instruction defines the SMTP client transfer settings for e-mail when the data recording file has been completed.

Parameters

Input

nLogID (WORD, INT, UINT)

LOG number (permissible range: 0–15). The compiler generates internally the string for the log file number, e.g. 'LOG=0'

sGroupNumber_Subject (STRING)

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 (max. 64 characters, one-byte):

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

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

      Automatically generated subjects:

      Japanese

      English

      ロギング/トレース (LOG0)

      Logging/Trace (LOG0)

      ロギング/トレース (LOG1)

      Logging/Trace (LOG1)

      ...

      ...

      ロギング/トレース (LOG14)

      Logging/Trace (LOG14)

      ロギング/トレース (LOG15)

      Logging/Trace (LOG15)

    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.

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

Examples:

  1. Destination group number 0, user-defined subject "LogFileTransmission": 'GRPNO=0,SUBJECT=LogFileTransmission'

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

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

sBodyText (STRING)

Message (max. 256 characters, one byte)

Specify the variable storing e-mail text or a character constant.

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=NONE': Do not add any information automatically

  • 'INFO=AUTO': Add automatically generated text

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

Japanese

English

基本項目

  • 送信元

  • CPU 型番(例:CPS41E)

  • IPv4 アドレス

  • IPv6 アドレス

  • ロギングトレース(ID 番号)

  • ファイル確定時刻

Basic information

  • From

  • CPU Part number (e.g. CPS41E)

  • IPv4 address

  • IPv6 address

  • Logging Trace ID

  • File fixed Time

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.

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

Attach the data recording file (LOG file) with the following keyword setting:

  • 'ATT=NONE': Do not attach the LOG file to the e-mail.

  • 'ATT=FILE': Attach the LOG file with the number specified by nLogID.

Examples:

  1. Do not add any information, do not attach the LOG file: 'INFO=NONE,ATT=NONE'

  2. Add automatically generated information, attach the LOG file: 'INFO=ADD,ATT=FILE'

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 parameters for the automatic text generation and file attachment cannot be omitted.

  • Separate all keyword entries by comma. e.g. 'NAME=abcd,FROM=sender@server.com'

  • Do not change the order of keywords. Specify the keywords and their setting parameters in the order they are listed here.

  • The number of characters for string data must not exceed 256.

  • This instruction is not available in interrupt programs.

  • 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.

  • Upper and lower case characters can be used for specifying keywords. However, the subject, the e-mail text, and the file name of the attachment are case-sensitive.

  • 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.

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

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

  • The instruction stores the e-mail settings for data recording of sGroupNumber_Subject, sBodyText and sAttachment in the LOG file number specified by nLogID.

  • 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 the transfer request flag for a specified nLogID number is TRUE, e.g. if sys_blsLog0DataRecordingActive is TRUE.

  • if the data recording condition of a specified nLogID number is not registered.

  • if a value specified for a parameter is outside the permissible range.

  • if the instruction is executed in an interrupt program

  • if the number of characters for string data exceeds 256.

  • 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 no e-mail transmission server is specified.

  • 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.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the transfer request flag for a specified nLogID number is TRUE, e.g. if sys_blsLog0DataRecordingActive is TRUE.

  • if the data recording condition of a specified nLogID number is not registered.

  • if a value specified for a parameter is outside the permissible range.

  • if the instruction is executed in an interrupt program

  • if the number of characters for string data exceeds 256.

  • 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 no e-mail transmission server is specified.

  • 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.

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
		bIsError: BOOL:=FALSE;
		bSetLogTransferSMTP: BOOL:=FALSE;
		bDisableLogTransferSMTP: BOOL:=FALSE;
	END_VAR

POU body

If bSetLogTransferSMTP and bDisableLogTransferSMTP are set to TRUE, 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 := 7 ;
        NETWORK_BODY
B(B_VARIN,,0,19,2,21,4,);
B(B_VARIN,,'GRPNO=0~SUBJECTAUTO',19,3,21,5,);
B(B_VARIN,,'Sent Log Files',19,4,21,6,);
B(B_VARIN,,'INFO=NON~ATT=NONE',19,5,21,7,);
B(B_VAROUT,,bIsError,39,2,41,4,);
B(B_CONTACT,,bSetLogTransferSMTP,5,1,7,3,);
B(B_F,FP_SMTP_SET_MODE_TRANSFER_LOG!,,21,0,39,7,,?DEN?DnLogID?DsGroupNumber_Subject?DsBodyText?DsAttachment?AENO?AbError);
L(1,2,5,2);
L(7,2,21,2);
L(1,0,1,7);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_CONTACT,,bDisableLogTransferSMTP,5,1,7,3,);
B(B_F,FP_SMTP_TRANSFER_CONTROL_LOG!,,21,0,39,5,,?DEN?DnLogID?DsControl?AENO?AbError);
B(B_VARIN,,0,19,2,21,4,);
B(B_VARIN,,'DISABLE',19,3,21,5,);
B(B_VAROUT,,bIsError,39,2,41,4,);
L(1,2,5,2);
L(7,2,21,2);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If (bSetLogTransferSMTP) Then
    FP_SMTP_SET_MODE_TRANSFER_LOG(nLogID := 0,
                                  sGroupNumber_Subject := 'GRPNO=0,SUBJECTAUTO',
                                  sBodyText := 'Sent Log Files', 
								  sAttachment := 'INFO=NON,ATT=NONE', bError => bIsError);
End_if;
If (bDisableLogTransferSMTP) Then
    FP_SMTP_TRANSFER_CONTROL_LOG(nLogID := 0,
                                 sControl := 'DISABLE', bError => bIsError);
End_if;

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