Send email via scripting

A forum devoted to the discussion of all topics having to do with scripting and other advanced programming using iX Developer.
Post Reply
BobLivingston
Posts: 19
Joined: Tue Jan 17, 2012 8:57 am

Send email via scripting

Post by BobLivingston »

I have some script that collects general health information from our machine that I would like to be able to email. The only method I've seen for sending emails is through the alarm server. I'm fine with this, but is there a way to create a "dummy" alarm that I can use as a pass-through to send my actual email text that will reset itself so I can use it again later for another email?
Bob Livingston
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA

Skylar
Posts: 42
Joined: Wed Jan 04, 2012 11:17 am

Re: Send email via scripting

Post by Skylar »

Bob,

There is a handy way to send emails with a script, and you can send whatever data you want. The script can even utilize the settings you already have configured in your alarm settings.

I have attached a sample project that demonstrates the functionality.
Attachments
Script_Email.zip
(108.47 KiB) Downloaded 904 times
Best Regards,

Beijer Electronics, Inc.
Skylar Walker | Applications Engineer

BobLivingston
Posts: 19
Joined: Tue Jan 17, 2012 8:57 am

Re: Send email via scripting

Post by BobLivingston »

Thanks Skylar.

Another related question - I've created a dialog to manage the SMTP server settings, but the settings are lost during a power cycle. What do I need to call to save the new server settings?
Bob Livingston
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA

BobLivingston
Posts: 19
Joined: Tue Jan 17, 2012 8:57 am

Re: Send email via scripting

Post by BobLivingston »

After some digging, I found I could save the config. settings using
Neo.ApplicationFramework.Common.XmlTypeSerializer.Save<IEmailDevice>(Path.Combine(ExecutionPath, "EmailDevice1.xml"), Globals.EmailDevice1);

I've tried to send an email through the Beijer, but I get the following error message: "Email could not be delivered due to Connection error". I have checked my SMTP server settings and they are correct. Is there something I am missing? (I'm using the example script above.)

Thanks.
Bob Livingston
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA

User avatar
Ron L.
Posts: 214
Joined: Fri Jul 15, 2011 3:21 pm

Re: Send email via scripting

Post by Ron L. »

Could be a fire wall issue, if you are testing the application on your PC, you can run the freeware program WireShark and view exactly what is happening on the network. Most likely you would see an attempt of a TCP/IP connection to your SMTP server that was rejected or a DNS request that failed to translate the SMTP server name to an IP address.
Best Regards,

Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer

Post Reply