ReceiveMail (FB)¶
FUNCTION_BLOCK ReceiveMail EXTENDS CBM.ETrigTo
The „ReceiveMail“ function block establishes a connection with the username and password from the „userInfo“ variable to the specified mail server and receives the oldest mail from the mailbox. Additionally the memory for the body text must be reserved in the „emailMemory“. When the text is longer than the size of the memory, the message is cut and an information is returned. In case there is an attachment, the folder where to save it to should be specified. If not the attachment will not be saved and an information is returned. To change the buffer size for reading an email, the parameter „iBufferReceive“ can be changed by selecting the library in the library manager and change the value.
- InOut:
Scope
Name
Type
Comment
Inherited from
Input
xExecuteBOOLRising edge: Action startsFalling edge: Resets outputsIf a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or in the event of an error. In this case, the corresponding output values (xDone,xError) are present at the outputs for exactly one cycle.ETrigTo
udiTimeOutUDINTDefines the time (µs) after which an FB (e.g. requiring an external acknowledgement) aborts operation due to a timeout with error message.
ETrigTo
Output
xDoneBOOLTRUE: Action successfully completedETrigTo
xBusyBOOLTRUE: Function block activeETrigTo
xErrorBOOLTRUE: Error occurred, function block aborts actionFALSE: No errorETrigTo
Inout
ServerFBInput
userInfoThese variables include authentication information to establish a connection to the mail server.
emailMemory- The memory allocation for the message text as well as the folder where an attachment should
be saved.
Output
eErrorLocal library error ID
ReceiveThis variable includes all important information from the received mail
sServerMessageSTRING(255)Detailed error message from the server