Email function errors

I get errors on the following code that works fine in FPMI. What am I missing?

body = "<HTML><BODY>Name: %s <br> Email: %s <br> %s <br><br></BODY></HTML>"%(contact_name,contact_email,query) recipients = ["david.mccutchen@us.michelin.com", "chris-d.sanders@us.michelin.com",contact_email] system.net.sendEmail("notesgwna.michelin.com", "ardmixdaq01@us.michelin.com", "Automated Email Alerts Update", body, 1, recipients)

error = 2010/02/08 12:48:18 | javax.mail.MessagingException: IOException while sending message; INFO | jvm 1 | 2010/02/08 12:48:18 | nested exception is: INFO | jvm 1 | 2010/02/08 12:48:18 | javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/html INFO | jvm 1 | 2010/02/08 12:48:18 | at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:676) INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.mail.Transport.send0(Transport.java:189) INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.mail.Transport.send(Transport.java:118) INFO | jvm 1 | 2010/02/08 12:48:18 | at com.inductiveautomation.ignition.gateway.script.GatewayNetUtilities.sendEmail(GatewayNetUtilities.java:148) INFO | jvm 1 | 2010/02/08 12:48:18 | at com.inductiveautomation.ignition.gateway.servlets.Gateway._sendEmail(Gateway.java:1595) INFO | jvm 1 | 2010/02/08 12:48:18 | at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(Gateway.java:445) INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) INFO | jvm 1 | 2010/02/08 12:48:18 | at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(MapServlet.java:85) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) INFO | jvm 1 | 2010/02/08 12:48:18 | at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) INFO | jvm 1 | 2010/02/08 12:48:18 | at java.lang.Thread.run(Unknown Source) INFO | jvm 1 | 2010/02/08 12:48:18 | Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/html INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source) INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.activation.DataHandler.writeTo(Unknown Source) INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403) INFO | jvm 1 | 2010/02/08 12:48:18 | at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1745) INFO | jvm 1 | 2010/02/08 12:48:18 | at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:636) INFO | jvm 1 | 2010/02/08 12:48:18 | ... 20 more

Hmm, that is curious. I cut and pasted your exact code (filling in my email for the email addresses) and it worked just fine for me.

A quick google search for the underlying error message from your stack trace: “no object DCH for MIME type text/html” shows a lot of chatter about this, but we’re going to have to try to reproduce it before we can fix it.

Can you report your OS and Java version please? Try flipping the “html” bit to 0 and report back if there is any difference.

We are running XP professional sevice pack 2 and Java 1.6.0_04-b12. Ignition is installed on the same machine as FPMI and FSQL which this code runs fine with. We tried just plain text and no variables and still get the same result. ??

As well as the email call out, which is not resolved, we are having trouble with this code:

# This code would get the entire table of sessions and put it in an adjacent table
table = event.source.getComponent('Users').getComponent('Table')
sessions = system.util.getSessionInfo()
table.data = system.dataset.toDataSet(sessions)

This works FINE in FPMI. We even tried to just use:

system.util.getSessionInfo()

But recieved the same error

Traceback (innermost last):
  File "<event:propertyChange>", line 3, in ?
com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Gateway Error 500: java.lang.Long cannot be cast to java.lang.Integer

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:236)

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:211)

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:201)

	at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.invoke(GatewayInterface.java:587)

	at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities.getSessionInfo(ClientSystemUtilities.java:204)

	at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities.getSessionInfo(ClientSystemUtilities.java:197)

	at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities.getSessionInfo(ClientSystemUtilities.java:193)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

	at java.lang.reflect.Method.invoke(Unknown Source)

	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)

	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:286)

	at org.python.core.PyObject.__call__(PyObject.java)

	at org.python.core.PyObject.invoke(PyObject.java)

	at org.python.pycode._pyx18.f$0(<event:propertyChange>:3)

	at org.python.pycode._pyx18.call_function(<event:propertyChange>)

	at org.python.core.PyTableCode.call(PyTableCode.java)

	at org.python.core.PyCode.call(PyCode.java)

	at org.python.core.Py.runCode(Py.java)

	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:367)

	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:138)

	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:280)

	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)

	at $Proxy0.propertyChange(Unknown Source)

	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)

	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)

	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)

	at java.awt.Component.firePropertyChange(Unknown Source)

	at javax.swing.JComponent.firePropertyChange(Unknown Source)

	at com.inductiveautomation.factorypmi.application.components.model.AbstractFPMIPanel.startupComponent(AbstractFPMIPanel.java:148)

	at com.inductiveautomation.factorypmi.application.FPMIWindow.startupComponents(FPMIWindow.java:274)

	at com.inductiveautomation.factorypmi.application.FPMIWindow.startupAdapters(FPMIWindow.java:265)

	at com.inductiveautomation.factorypmi.application.FPMIApp.openWindow(FPMIApp.java:909)

	at com.inductiveautomation.factorypmi.application.FPMIApp.openWindow(FPMIApp.java:852)

	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities$1.run(NavUtilities.java:176)

	at com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities.doGUIAction(WindowUtilities.java:511)

	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.swapWindow(NavUtilities.java:174)

	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.swapTo(NavUtilities.java:92)

	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.swapTo(NavUtilities.java:75)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

	at java.lang.reflect.Method.invoke(Unknown Source)

	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)

	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:286)

	at org.python.core.PyObject.__call__(PyObject.java)

	at org.python.core.PyObject.invoke(PyObject.java)

	at org.python.pycode._pyx13.f$0(<event:mouseReleased>:8)

	at org.python.pycode._pyx13.call_function(<event:mouseReleased>)

	at org.python.core.PyTableCode.call(PyTableCode.java)

	at org.python.core.PyCode.call(PyCode.java)

	at org.python.core.Py.runCode(Py.java)

	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:367)

	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:138)

	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:280)

	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)

	at $Proxy1.mouseReleased(Unknown Source)

	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)

	at java.awt.Component.processMouseEvent(Unknown Source)

	at javax.swing.JComponent.processMouseEvent(Unknown Source)

	at java.awt.Component.processEvent(Unknown Source)

	at java.awt.Container.processEvent(Unknown Source)

	at java.awt.Component.dispatchEventImpl(Unknown Source)

	at java.awt.Container.dispatchEventImpl(Unknown Source)

	at java.awt.Component.dispatchEvent(Unknown Source)

	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

	at java.awt.Container.dispatchEventImpl(Unknown Source)

	at java.awt.Window.dispatchEventImpl(Unknown Source)

	at java.awt.Component.dispatchEvent(Unknown Source)

	at java.awt.EventQueue.dispatchEvent(Unknown Source)

	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

	at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer

	at com.inductiveautomation.ignition.gateway.servlets.gateway.functions.GetSessionInfo.invoke(GetSessionInfo.java:51)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at sun.reflect.NativeMethodAccessorImpl.invoke(null)

	at sun.reflect.DelegatingMethodAccessorImpl.invoke(null)

	at java.lang.reflect.Method.invoke(null)

	at com.inductiveautomation.ignition.gateway.servlets.gateway.AbstractGatewayFunction.invoke(AbstractGatewayFunction.java:152)

	at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(Gateway.java:375)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)

	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

	at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(MapServlet.java:85)

	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)

	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)

	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

	at java.lang.Thread.run(null)


com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Gateway Error 500: java.lang.Long cannot be cast to java.lang.Integer

	at org.python.core.Py.JavaError(Py.java)
	at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities.getSessionInfo(ClientSystemUtilities.java:208)
	at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities.getSessionInfo(ClientSystemUtilities.java:197)
	at com.inductiveautomation.factorypmi.application.script.builtin.ClientSystemUtilities.getSessionInfo(ClientSystemUtilities.java:193)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:286)
	at org.python.core.PyObject.__call__(PyObject.java)
	at org.python.core.PyObject.invoke(PyObject.java)
	at org.python.pycode._pyx18.f$0(<event:propertyChange>:3)
	at org.python.pycode._pyx18.call_function(<event:propertyChange>)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyCode.call(PyCode.java)
	at org.python.core.Py.runCode(Py.java)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:367)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:138)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:280)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
	at $Proxy0.propertyChange(Unknown Source)
	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
	at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
	at java.awt.Component.firePropertyChange(Unknown Source)
	at javax.swing.JComponent.firePropertyChange(Unknown Source)
	at com.inductiveautomation.factorypmi.application.components.model.AbstractFPMIPanel.startupComponent(AbstractFPMIPanel.java:148)
	at com.inductiveautomation.factorypmi.application.FPMIWindow.startupComponents(FPMIWindow.java:274)
	at com.inductiveautomation.factorypmi.application.FPMIWindow.startupAdapters(FPMIWindow.java:265)
	at com.inductiveautomation.factorypmi.application.FPMIApp.openWindow(FPMIApp.java:909)
	at com.inductiveautomation.factorypmi.application.FPMIApp.openWindow(FPMIApp.java:852)
	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities$1.run(NavUtilities.java:176)
	at com.inductiveautomation.factorypmi.application.script.builtin.WindowUtilities.doGUIAction(WindowUtilities.java:511)
	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.swapWindow(NavUtilities.java:174)
	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.swapTo(NavUtilities.java:92)
	at com.inductiveautomation.factorypmi.application.script.builtin.NavUtilities.swapTo(NavUtilities.java:75)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:286)
	at org.python.core.PyObject.__call__(PyObject.java)
	at org.python.core.PyObject.invoke(PyObject.java)
	at org.python.pycode._pyx13.f$0(<event:mouseReleased>:8)
	at org.python.pycode._pyx13.call_function(<event:mouseReleased>)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyCode.call(PyCode.java)
	at org.python.core.Py.runCode(Py.java)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:367)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:138)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:280)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
	at $Proxy1.mouseReleased(Unknown Source)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Ignition v7.0.1 (b4461)
Java: Sun Microsystems Inc. 1.6.0_11

That second issue has been fixed for the next release.

Any resolve on the email issue?

Hi David,

It looks like this is an issue with Java version 1.6.0_04. If you update to the newest version of Java it will work correctly.

Will all clients need to be upgraded or just the server?

This resolved the issue by updating to Java 1.6.0_18-b07 on the server. Thanks for you help

Great, glad its working. Just so you know, only the version of Java running the Gateway is pertinent for this workaround, so you don’t need to worry about the clients.