Page 1 of 1

Send email via scripting

Posted: Wed Feb 08, 2012 3:29 pm
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?

Re: Send email via scripting

Posted: Wed Feb 08, 2012 4:40 pm
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.

Re: Send email via scripting

Posted: Thu Feb 09, 2012 3:27 pm
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?

Re: Send email via scripting

Posted: Fri Feb 10, 2012 10:23 am
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.

Re: Send email via scripting

Posted: Fri Feb 10, 2012 11:28 am
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.