ns=2;s=DEPRAG Smart/Network/EMailClient/SendWithAttachments
This command sends an e-mail message with attachments to all e-mail addresses stored in the MailAddressTo field. File attachments are passed in the AttachmentFilePaths field. Before using the functionality, the SMTP server must be set in the SmtpServerSettings settings.
In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:
VAR
EmailAddressArray : ARRAY[1..50] OF STRING(255) := ['employee@example.com'];
EmailAttachmentsArray : ARRAY[1..50] OF STRING(255) := ['C:\Test\text.txt'];
bEMailClientSendWithAttachments : BOOL;
OutputDataEMailClientSendWithAttachments : ST_VoidOutputData;
hrEMailClientSend : HRESULT;
testShortByteArray : ARRAY[1..10] OF BYTE := [84, 101, 115, 116];
testLongByteArray : ARRAY[1..1000] OF BYTE := [84, 101, 115, 116, 255, 84, 255];
fbEMailClient : FB_EMailClient;
END_VAR
hrEMailClientSendWithAttachments := fbEMailClient.EMailClientSendWithAttachments(
bExecute := bEMailClientSendWithAttachments,
ConnectionHandle := depragSmartConnection.ConnectionHandle,
sMailAdressFrom := 'test@deprag.de',
MailAddressTo := EmailAddressArray,
nNumberOfAddressesToMailTo := 1,
sSubject := ADR(testShortByteArray),
SizeOfSubject := SIZEOF(testShortByteArray),
sContent := ADR(testLongByteArray),
SizeOfContent := SIZEOF(testLongByteArray),
AttachmentFilePaths := EmailAttachmentsArray,
nNumberOfAttachmentFilePaths := 1,
OutputData => OutputDataEMailClientSendWithAttachments);
IF hrEMailClientSendWithAttachments <> S_FALSE THEN
bEMailClientSendWithAttachments := FALSE;
END_IF
For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".