Send email via scripting
-
- Posts: 19
- Joined: Tue Jan 17, 2012 8:57 am
Send email via scripting
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
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA
Re: Send email via scripting
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.
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 1141 times
Best Regards,
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
Beijer Electronics, Inc.
Skylar Walker | Applications Engineer
-
- Posts: 19
- Joined: Tue Jan 17, 2012 8:57 am
Re: Send email via scripting
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?
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
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA
-
- Posts: 19
- Joined: Tue Jan 17, 2012 8:57 am
Re: Send email via scripting
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.
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
Sr Controls Engineer
FlexEnergy Energy Systems
30 New Hampshire Ave
Portsmouth, NH 03801
USA
Re: Send email via scripting
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
Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer