Receiving email – AMX i!-EquipmentMonitor User Manual

Page 8

Advertising
background image

Running i!-EquipmentMonitor

4

i!-EquipmentMonitor

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('[email protected]',

'[email protected] ',

'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,

i!-EquipmentMonitorOut attempts to open this file from the Master’s file system and include it as

an attachment to the email. Binary files are not supported at this time so the file must be ASCII

(text) only. If the file does not exist or cannot be opened, an error is printed to the terminal, but the

email is still sent without an attachment.

Receiving Email

To support receiving email, first include the i!-EquipmentMonitorIn.axi (page 11) into you

program:

#INCLUDE 'i!-EquipmentMonitorIn.axi' // Include to get email

Next, make sure that the default IP local port used by i!-EquipmentMonitorIn.axi is available on

your system.

i!-EquipmentMonitorIn.axi uses local port 0:11:0 for sending emails. Make sure there is no current

entry in your

DEFINE_DEVICE

section for 0:11:0. If there is a current entry for 0:11:0, you can

change the existing entry to another local port number or override the default local port used by i!-

EquipmentMonitorIn.axi like this in the

DEFINE_DEVICE

section:

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:

Advertising