This function enables a controller to send an e-mail in response to Ladder conditions. In order to send e-mail, the controller must comprise a TCP/IP port, and must be connected to an Ethernet network with access to a mail server.
Before you begin you need the following information:
The type of protocol your mail server uses, SMTP or ESMTP
Your mail server's IP address
There are sample applications that show how e-mail may be sent via Ethernet, and via GPRS modem.
To determine which protocol your server supports, run Telnet.
Note ♦ |
Telnet is not enabled by default in Windows Vista/7. To enable Telnet:
|
Click Windows Start > Run, then enter CMD.
In the CMD window, enter the command: telnet RemoteMailServer 25, where RemoteMailServer is the name of your mail server, and 25 is the port via which you contact the server. The command returns the protocol type used by the server.
Use the 'ping' command to determine the IP address of your mail server.
Click Windows Start > Run, then enter CMD.
In the CMD window, enter the command: ping RemoteMailServer, where RemoteMailServer is the name of your mail server; the command returns the IP address of the server.
If your controller is sending e-mail to addresses within a local network, and you know the name of the server in your network, communicate with it directly.
Note that you can also send e-mail via GPRS modem. When you prepare the modem via Modem Services, set it to a baud rate of 9600. In addition, the COM Init function should be set to 9600.
Configure Ethernet in your application by building a net that comprises the following elements:
|
|
Note ♦ |
Dedicate one socket to sending e-mail. |
Establish the Ethernet Connection using the Com>TCP/IP> TCP/IP Connect Socket function. The function must be configured to your mail server IP, and to Port 25, which is the outgoing messages port.
Note ♦ |
It is recommended that you include a time elapse of a few seconds after the Ethernet Card initializes and before activating Socket Connect. A timer may be used for this purpose. |
Send the e-mail using the Com>Send e-mail function.
Use the appropriate SB to ensure that the socket is connected before sending the e-mail.
Use the status of SB 345 Email Send in Progress to avoid communication conflicts and ensure that the e-mail function is free before sending the e-mail. This bit turns ON when the e-mail function is activated, and turns OFF when the message has been sent to the server.
Note that:
- only one e-mail can be sent at a time, and that an application should use the same socket to send all e-mails.
- you can send a number of e-mails before closing the connection.
Close the connection and free the socket using the Com>TCP/IP>TCP/IP Close Socket function.
After closing the socket, wait 30 seconds before sending additional e-mails.
Fill in the parameters according to the parameter table given below
Parameter Name |
Purpose |
Protocol |
Select the protocol your server uses. Both SMTP and ESMTP are supported. |
Socket |
Select the socket you are using for this function. |
From |
You can either type in an address, or link a vector of registers |
To/Cc/Bcc |
You can select up to 8 recipients per category Click a line to open the address book. |
Subject |
Click to enter text or link a vector. The vector will end either at a null character, or when reaching the maximum of 50 characters |
Attached |
Enhanced Vision controllers with SD cards enable you to attach up to 8 files from the SD card. Click to set the attachment names. Note that: - The file name must adhere to the 8.3 file format, up to 8 characters for the name, 3 for the extension. - File name may be provided by constant text or register. Note that if the name comes from an MI, the function copies a vector 8 bytes long, or until it finds a 'null' character - The size of the attachments is limited in SI 58. maximum attachment size is 10 MB. - Power-up default is 1 - Maximum per attachment = 10 (10 MB) Note that the file size must not be changed while the Send is in Progress. |
Direct mail content |
Select to type your e-mail message into the content field. You can enter up to 800 characters. |
Indirect mail content |
Select to link to a vector. The vector will end either at a null character, or when reaching the maximum of 800 characters |
The following operands should be assigned Power-up Values; bits should be reset, and registers initialized to 0. |
|
Status Messages |
When the In Progress bit turns ON, the current status message turns from 0 to 1. When the Status Message 0 – IDLE 1 – IN PROGRESS 2 - SUCCESS 3 – SMTP server does not respond ( HELO command Failed) 4 – ESMTP server does not respond ( EHLO command Failed) 5 – 'From' address format incorrect 6 – 'To/Cc/Bcc' address format incorrect. Check Address Status Operand 7 – The server cannot receive data (DATA mode error) 8 – Mail was not sent: error occurred while sending e-mail header (name, subject, etc..) 9 - Mail was not sent: error occurred while sending e-mail data (text, attachments, etc..) 10 - Mail was not sent: error occurred while sending e-mail end of data/closing the e-mail 11 – Mail was not sent: error occurred since authentication is not enabled or it's not supported 12 – Mail was not sent: error occurred while sending username with authentication mode 13 – Mail was not sent: error occurred while sending password with authentication mode 14 – Mail was not sent: error occurred while sending username with plain login mode 15 – Mail was not sent: error occurred while sending password with plain login mode |
Recipients Status |
If the Status Message is 6, use this register to determine which addresses are in incorrect format.
The bit corresponds with the incorrect address. If, for example, bit 9 is ON, the address on the second Cc line is incorrect. |
System Operands
# |
Description |
Value |
Comments |
SI 58 |
email: Limit File Attachment Size |
1=1024 bytes |
Note that the file size must not be changed while the Send is in Progress. |
SI 59 |
Send e-mail: Increase Timeout |
resolution=10 ms |
In some applications, such as those relying on slower cellular routers, the Send e-mail process may require added time. Use this to add that time. |
Note ♦ |
The function does not support authentication, SSL or TSL encryption. |