Mail dispatch
With the function block FB_SmtpV3 the encrypted mail dispatch via TLS or STARTTLs is available.
Description
An email is sent after triggering the variable bStart.
ToDo: configure the mail server address and credentials.
Program variables
PROGRAM MAIN
VAR
fbSendMail: FB_SmtpV3;
sMessage: STRING := 'Hello Beckhoff';
R_Edge: R_TRIG;
bStart: BOOL;
bBusy: BOOL;
bError: BOOL;
nErrID: UDINT;
bSend: BOOL;
nErr: UDINT;
nMailCounter: UDINT;
END_VAR
Program code
fbSendMail(
sNetId:= '',
sSmtpServer:= 'mail.company.com',
sUsername:= 'TestUser',
sPassword:= 'TestPwd',
sFrom:= 'TestUser@company.com',
sTo:= 'service@company.com',
sSubject:= 'Email from your Beckhoff PLC',
pMessage:= ADR(sMessage),
cbMessage:= SIZEOF(sMessage),
bExecute:= bStart,
bError=> bError,
bBusy=> bBusy,
nErrId=> nErrId);
IF NOT bBusy AND NOT bError AND bStart THEN
bStart := FALSE;
END_IF
Requirements
Development environment |
Target system type |
PLC libraries to be linked |
---|---|---|
TwinCAT v3.0.0 |
PC or CX (x86) |
Tc2_Smtp |