Cicode Programming Reference > Cicode Function Categories > Mail Functions > MailRead

MailRead

Reads a standard mail message. The mail message can contain text, an attached file, or both.

This function is a blocking function. It blocks the calling Cicode task until the operation is complete.

Before you can use this function, you need to use the MailLogon() function to log on to the mail system. You can only read mail sent to the user name specified in the MailLogon() function.

Syntax

MailRead(sName, sSubject, sNote, sFileName, iMode)

sName:

The name of the mail user who sent the message. Must be a String type variable.

sSubject:

The subject text of the mail message. Must be a String type variable.

sNote:

The note section of the message. If the message is longer than 255 characters, Citect SCADA will save the message in a file and return the file name in sNote. Use the file functions to read the message. The name of the file will be in the form CTxxxxx where x is a unique number. You need to delete the file after you have finished with the mail message. Must be a String type variable.

sFileName:

The name of any attached file. If there is no attached file in the message, specify sFileName as an empty string "". Must be a String type variable.

iMode:

The mode of the read:

0 - Read a message. If no message is available, wait for a message.

1 - Read a message. If no message is available, return with an error code.

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

MailLogon, MailLogoff, MailSend, MailError

Example

! Logon to the mail system
MailLogon("RodgerG", "password", 0);
! Read a message. Don't wait if no message
IF MailRead(sName, sSubject, sNote, sFileName, 1) = 0 THEN
! got message now do something with it
END
WHILE TRUE DO
! wait for a mail message
MailRead(sName, sSubject, sNote, sFileName, 0);
END;
MailLogoff();

See Also

Mail Functions

Published June 2018