Error sending email

Hi,

With V7.4.1 and system.net.sendEmail, I’ve an annoying error while the message is well send to the recipient.
Any idea is welcome :wink:

The event is fire by a PropertyChange event :

if event.propertyName == "emailReport":
	if event.newValue == 1:
	tomail = event.source.getComponent('toEmail').text
	#print tomail
      	report = event.source.getComponent('Report Viewer')
      	bytesPDF = report.getBytesPDF()
      	system.net.sendEmail("smtp.mydomain.com", "Ignition-automated-reports@mydomain.com", "Alarm Message", "text message", 0, [tomail], ["Rapport Alarmes.pdf"], [bytesPDF], 60000*5, "from@mydomain.com", "mypwd")

I’ve the following error :

Traceback (most recent call last):
  File "<event:propertyChange>", line 7, in <module>
NameError: name 'email' is not defined

	at org.python.core.PyException.fillInStackTrace(PyException.java:70)
	at java.lang.Throwable.<init>(Throwable.java:181)
	at java.lang.Exception.<init>(Exception.java:29)
	at java.lang.RuntimeException.<init>(RuntimeException.java:32)
	at org.python.core.PyException.<init>(PyException.java:46)
	at org.python.core.PyException.<init>(PyException.java:43)
	at org.python.core.PyException.<init>(PyException.java:61)
	at org.python.core.Py.NameError(Py.java:246)
	at org.python.core.PyFrame.getname(PyFrame.java:257)
	at org.python.pycode._pyx1.f$0(<event:propertyChange>:9)
	at org.python.pycode._pyx1.call_function(<event:propertyChange>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1261)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:537)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:152)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:260)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
	at $Proxy14.propertyChange(Unknown Source)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
	at java.awt.Component.firePropertyChange(Component.java:8248)
	at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.inductiveautomation.factorypmi.application.binding.util.DynamicPropertyUtil.firePropertyChange(DynamicPropertyUtil.java:246)
	at com.inductiveautomation.factorypmi.application.binding.util.DynamicPropertyUtil.setPropertyValue(DynamicPropertyUtil.java:237)
	at com.inductiveautomation.vision.api.client.components.model.AbstractVisionPanel.setPropertyValue(AbstractVisionPanel.java:116)
	at com.inductiveautomation.factorypmi.application.binding.AbstractPropertyAdapter.updateTarget(AbstractPropertyAdapter.java:275)
	at com.inductiveautomation.factorypmi.application.binding.SimpleBoundTagAdapter.updateTarget(SimpleBoundTagAdapter.java:513)
	at com.inductiveautomation.factorypmi.application.binding.AbstractPropertyAdapter.updateValue(AbstractPropertyAdapter.java:240)
	at com.inductiveautomation.factorypmi.application.binding.SimpleBoundTagAdapter.notifyTagChanged(SimpleBoundTagAdapter.java:479)
	at com.inductiveautomation.factorypmi.application.binding.SimpleBoundTagAdapter.tagChanged(SimpleBoundTagAdapter.java:469)
	at com.inductiveautomation.ignition.client.sqltags.impl.db.DatasourceTagManager$TagChangeListenerProxy.tagChanged(DatasourceTagManager.java:1054)
	at com.inductiveautomation.ignition.client.sqltags.impl.ChangeNotifier.run(ChangeNotifier.java:38)
	at com.inductiveautomation.ignition.client.sqltags.impl.db.BatchNotifier.run(BatchNotifier.java:78)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:682)
	at java.awt.EventQueue.access$000(EventQueue.java:85)
	at java.awt.EventQueue$1.run(EventQueue.java:643)
	at java.awt.EventQueue$1.run(EventQueue.java:641)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:652)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Ignition v7.4.1 (b906)
Java: Apple Inc. 1.6.0_31

If the spacing you show in your code block (below) is correct, this could explain it…

[quote]if event.propertyName == "emailReport": if event.newValue == 1: tomail = event.source.getComponent('toEmail').text #print tomail report = event.source.getComponent('Report Viewer') bytesPDF = report.getBytesPDF() system.net.sendEmail("smtp.mydomain.com", "Ignition-automated-reports@mydomain.com", "Alarm Message", "text message", 0, [tomail], ["Rapport Alarmes.pdf"], [bytesPDF], 60000*5, "from@mydomain.com", "mypwd")[/quote]

Try this:

if event.propertyName == "emailReport": if event.newValue == 1: tomail = event.source.getComponent('toEmail').text #print tomail report = event.source.getComponent('Report Viewer') bytesPDF = report.getBytesPDF() system.net.sendEmail("smtp.mydomain.com", "Ignition-automated-reports@mydomain.com", "Alarm Message", "text message", 0, [tomail], ["Rapport Alarmes.pdf"], [bytesPDF], 60000*5, "from@mydomain.com", "mypwd")

Sorry,

The spacing in my quoted code is wrong. In the script editor, it is the way you corrected it.

Thanks.

You are looking at the wrong script. The error is coming from a tag change event script in the client. You are looking at a propertyChange event that doesn’t even have a variable called “email”.