Running
Now, all you need to do is call the function that sends an email. If you want to send an email every time someone presses a button on a touch panel, your code would look like this:
BUTTON_EVENT[dvTP,1]
{
PUSH:
{
SmtpQueMessage('fromAddress@mydomain.com', 'toAddress@mydomain.com ', 'My Emails subject’,
'this is the body of my email! Wow, this is Cool!', '')
}
}
The call to SmtpQueMessage() causes your email to queue and transmit to the SMTP server. The maximum number of emails that can be queued is controlled by the constant SMTP_MAX_EMAILS, which defaults to 10. You can override this value if you choose; you will probably never have a need to since the emails are sent very quickly.
The parameters to SmtpQueMessage() control where your email will be sent. The first parameter is the From Email Address. This usually does not have to be a real email address but some SMTP server configurations may require a valid one. It is best to obtain an email address from your email administrator.
The second parameter is the To Email Address. This can be a list of addresses separated by a ";" so you can send an email to more than one recipient in a single call to SmtpQueMessage(). The next two parameters are the subject and message of the email. The message can be up to SMTP_MSG_MAX characters long (the default value is 2000 but you can override it if necessary).
The last parameter is an attachment file name. If you supply a value for this parameter,
Receiving Email
To support receiving email, first include the
#INCLUDE | // Include to get email |
Next, make sure that the default IP local port used by
dvPop3Socket = 0:4:0
Next, you need to initialize the POP3 server value by calling Pop3SetServer (). You will need the name or IP address of your local POP3 server, provided by your Network administrator. Using a name for the server is acceptable if you have DNS properly configured on the NetLinx Master.
Otherwise, you will need an IP address. Once you have the correct POP3 server name or address, call Pop3SetServer like this:
| 4 | |
|
|
|