Hello all,
I wonder, is there any way sending email in the script of tags? I looked the manual and some topics, almost all of them related to gateway or another section in the ignition. I couldn’t find out any example inside the tags scripts.
For example;

I have a memory tag as above and it has some script codes for get data from MES system. It’s working for now, but I have some if&else condition into this script of tag and I want to send email if run my “else” condition and give detail information about process.
Is it possible this? Can I manage this directly over memory tag?
Edit:
When I try this script in the console, I get error as following.
body = "Hello, this is an email."
recipients = ["test1@gmail.com"]
system.net.sendEmail("mail.mycompany.com",
"myemail@mycompany.com", "Here is the email!", body, 0, recipients)```
Output
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Error sending email. Session id=BB58AF7B
Thanks
You’ll need a valid smtp server and emails configured.
With that done, this should work as expected. I’m using this function to send mails and it works fine.
1 Like
Ok, I understood. I’ll check my SMTP configuration. Thanks!
Hi @pascal.fragnoud , Configured where?
You can configure a SMTP profile from the gateway config:
Then specify which profile you want to use something like this, use your actual profile name.
system.net.sendEmail(smtpProfile="smtp_server", fromAddr="myemail@mycompany.com", subject="Here is the email!", body=body, html=1, to=recipients, cc=cc_recipients)
You can also just specify the SMTP server IP or DNS name in the sendEmail call but I think its better to use a profile configured on the gateway.
1 Like
I suggest making any script email with,
fromAddr = scriptname.appname@IgnitionGatewayName.myCompany.com
and have the name generated by script so that it updates automatically if you copy the script into another gateway or project.
This way, if the script goes rogue and IT are threatening to take your toys you should be able to identify the source of the problem very quickly.
1 Like