-

Y_CO_SendEmail

Image
This function block sends an e-mail via SMTP commands (Simple Mail Transfer Protocol) through a specified SMTP server. The output is highly configurable including multiple recipients, any message body structure, specified sender e-mail and name and other features listed below.

Parameters

* Parameter Data Type Description Default
VAR_IN_OUT
V MessageBody Yt_ByteArray4096 The e-mail body as a 4096 element byte array. If a larger body is required, this declaration can be changed and the library recompiled.
V MessageData Yt_CO_SMTP_Data A user customized data structure for configuring the e-mail block.
VAR_INPUT
B Execute BOOL Upon the rising edge, all other function block inputs are read and the function is initiated. To modify an input, change the value and re-trigger the execute input. FALSE
V BodyLength UDINT The length (number of bytes) of the e-mail body that will be sent. While not necessary it is highly suggested, see notes below. UDINT#0
VAR_OUTPUT
B Done BOOL Set high upon successfully sending an e-mail.
B Busy BOOL Set high upon the start of communications with the SMTP server and low when 'Done' or 'Error' go high.
B Error BOOL Set high when an error occurs during e-mail configuration and sending. Set low upon Execute being reset.
E ErrorID UINT If Error is true, this output provides the ErrorID. Cleared upon 'Execute' being reset.
V ErrorString Yt_String256 If 'Error' is true and it is an SMTP response code related error then this output contains the response string from the SMTP server.

Notes

Error Description

See the Function Block ErrorID List.

Example

The example shown here sets up the block, creates a message body and sends an e-mail to external Gmail account.

The variable EmailBodyString is of type Yt_STRING256. Below is the configuration of the Yt_CO_SMTP_Data structure:

The most basic form of sending an e-mail is simply converting a string to a byte array via the STRING_TO_BUF function block. With the data structure shown above and this STRING_TO_BUF block, the email is configured and ready for use.

After toggling PrepareMessage, here is the result.


And to demonstrate the end result, here is the e-mail in the inbox of the Gmail account used. The sender and subject are both listed correctly and a portion of the send message can be seen.



 


This help information is valid for iCube Engineer Online Help 2025.6

Copyright © 2025 YASKAWA EUROPE GmbH and © 2025 YASKAWA America, Inc.