This function configures the email settings used by other features in the project that can send email, such as Alarm worksheets and the SendEmail and SendEmailExt functions.
Function | Group | Execution | Windows | Embedded | Thin Client |
---|---|---|---|---|---|
CnfEmail | Synchronous | Supported | Supported | Supported |
This is an optional parameter; if no timeout is specified, then the project will keep trying forever until it receives a response. You should specify some timeout, however, to make sure that your project won't freeze.
Please note that if your SMTP username and password are the same as your POP3 username and password, then you can skip optStrSMTPUser and optStrSMTPPassword. The project will automatically use the values from strUser and strPassword.
Value | Description |
---|---|
0 | Success |
1 | Invalid format for strSMTP |
2 | Invalid format for strFrom |
3 | Invalid format for strPOP3 |
4 | Invalid format for strUser |
5 | Invalid format for strPassword |
6 | Invalid format for optNumTimeout |
7 | Wrong number of parameters |
8 | Error getting host IP address (invalid POP3 server) |
9 | Error connecting to POP3 server |
10 | Error sending username |
11 | Error sending password |
12 | SMTP server does not support selected authentication mode |
13 | Invalid SMTP username |
14 | Authentication failed |
The email configuration created by this function works only within the Windows process where the function was called.
For example, if you place a Button object in a screen and then set the object to call this function when it is pressed, then the resulting email configuration will work only on the Client station where the screen is displayed and the button is pressed. It will not work on any other Client stations nor on the Server station, because the project viewer running on the Client station only exchanges data (i.e., changes in tag values) with the data server running on the Server station. One cannot directly call functions on the other; it can only use triggers to force the other to call functions. Please note that is true even when the Client station and the Server station are the same physical device, because the project viewer and the data server are still two separate processes in Windows.
If you want an email configuration to apply to your project's Background Task — for example, to be able to send emails when alarms become active — then you must call this function in some place like the project's Startup Script, a Script Group, or a Math worksheet.
CnfEmail( "smtp.company.com", "Robert@company.com", "pop.company.com", "RobertH", "Shades556", 100 )
CnfEmail( "smtp.company.com:4455", "Robert@company.com", "pop.company.com:9900", "RobertH", "Shades556", 5, 1 )
CnfEmail( "195.11.22.33:4455", "Robert@company.com", "195.66.77.88:9900", "RobertH", "Shades556", 5, 1, "JohnS", "abcd1234" )