Sending Reports By Email Issue

Hi everyone.

I am trying to send Reports Via emails but when i setup the SMTP profile i am not able to send emails and i get the error attached every time.
error
SMTP

Thank you in advance for your help,

Is your gateway able to connect to the internet? Is there a firewall blocking connections to smtp-mail.outlook.com?

Hi, yes my gateway is connected to internet and i am able to ping successuly : smtp-mail.outlook.com

you can, or can you do that from a terminal running on the same server as the gateway?

Regardless, you have a networking problem to solve, not a configuration issue in Ignition.

Trying to find other examples of SMTP connections to outlook - might try variations of those StartTLS / SSL settings in the meantime.

Thak you Kevin ,I pinged smtp-mail.outlook.com from the same server as the gateway , and i even desabled the firwall ,

Having the same issue. Can ping smtp.office365.com from server, can send test email from gateway, but script system.net.sendEmail( "smtp.office365.com", sender, email_subject, email_body, 1, email_to, [fileName], [fileData]) does not work.

What does "does not work" mean and look like?

1 Like

Traceback (most recent call last):
File "input", line 29, in module
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:351)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:325)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendEmail(GatewayInterface.java:693)
at com.inductiveautomation.ignition.client.script.ClientNetUtilities._sendEmail(ClientNetUtilities.java:55)
at com.inductiveautomation.ignition.common.script.builtin.AbstractNetUtilities.sendEmail(AbstractNetUtilities.java:170)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Error sending email. Session id=57D42CCC

Is there a certain format for the smtp string in the sendEmail command if STARTTLS is used?

To clarify, I can send a test email from the gateway so I know there is communication out. However, when I put the hostname "smtp.office365.com" or "smtp.office365.com:587" in the actual script, it fails with that error.

If you specify the host as smtp.office365.com:$port:tls, where $port is the actual port, it will use TLS and automatically try to use StartTLS.

This particular way of using sendEmail is deprecated though. Set up an email profile in the gateway and reference that in the arguments instead.

Is there more to that error, or a corresponding error in the gateway logs?

https://docs.inductiveautomation.com/display/DOC81/system.net.sendEmail

check out the last code example that uses keyword args to send by profile.

That worked mostly, but the attachments still error out. What are the keys for the pairs for attachments?

And thank you!

Docs suggest attachmentNames and attachmentData

1 Like

Thank you, I saw those in the brackets and assumed that it was meant as the value and not the key name.

This did it! Thanks for your help!