Send report by Email

Hi,
Can i send generated report automatically by Email?? . i Have reporting Module Ver: 1.5
I have active-x component .How can i import this active-x in designer?
Thanks.
Tamer

You can send a report automatically via email only if a client is open. Typically, people open a client on the server machine and make a screen that will generate the report and email it at various times throughout the day. You can use Ignition’s email function:

inductiveautomation.com/supp … demail.htm

You can get the bytes of a PDF by doing the following:report = event.source.parent.getComponent("Report") pdfBytes = report.getBytesPDF()

Ok, I am trying to send an email with a PDF of a report viewer component as an attachment. I am getting the PDF bytes just fine, but I get a MIME type error when I try to send the message:

“caused by GatewayException: Error sending email.
caused by javax.mail.internet.ParseException: Expected MIME type, got null”

Googling around, it might be that the Content-Type isn’t set correctly. Is there any way to set this, or should I be doing this another way?

[code]from java.util import Date
from java.util import Calendar
cal = Calendar.getInstance()
cal.setTime(Date())
todayDateStr = system.db.dateFormat(cal.getTime(), “MM/dd/yyyy”)

report=event.source.parent.getComponent(‘Report Viewer’) #Get Report

attachmentData=[report.getBytesPDF()] #Make into PDF data for email
attachmentNames=[“Report”]
smtp1 = “XXXXX”
sender = “XXXXX”
recipients = [“XXXXXX”]
subject = “Ignition Email Report for (” + todayDateStr + “)”
body = “”"
Report Data goes here
Another line of text
“”"
system.net.sendEmail(smtp1, sender, subject, body, 0, recipients, attachmentNames, attachmentData)
[/code]

Stack Trace:
Caused by: javax.mail.internet.ParseException: Expected MIME type, got null
at javax.mail.internet.ContentType.(ContentType.java:95)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1331)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1021)
at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:419)
at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1354)
at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2107)
at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2075)
at javax.mail.Transport.send(Transport.java:123)
at com.inductiveautomation.ignition.gateway.script.GatewayNetUtilities.sendEmail(GatewayNetUtilities.java:151)
at com.inductiveautomation.ignition.gateway.servlets.Gateway._sendEmail(Gateway.java:1403)
at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(Gateway.java:437)
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:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(null)

What version of Ignition are you using? I believe there was an issue with the 7.6 or 7.6.1 version that caused a similar error message. Upgrading solved the issue.

There was an issue and it was fixed for Ignition 7.6.1 in regards to email attachments. If upgrading does not work please let us know what version of Ignition you are using.

I am still seeing this error.

I am using stunnel for a secure connection to get to Gmail to send the email.
I am trying to attach a PDF of the Report Viewer to the email.

If I use None / None for the attachment Name / attachment Data, it works great and goes right through.

If I put in the name / data, I get the following error:

Traceback (most recent call last):

File “event:actionPerformed”, line 8, in

com.inductiveautomation.ignition.client.gateway_interface.GatewayException: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Error sending email.

caused by GatewayException: Error sending email.
caused by javax.mail.internet.ParseException: Expected MIME type, got null

Ignition v7.6.2 (b2368)
Java: Sun Microsystems Inc. 1.6.0_45

Try adding .pdf to report name

attachmentNames=["Report.pdf"]

Just went through this problem.

1 Like

Exactly right! Thanks so much. :smiley:

Lance

Glad to hear it is working!

Is it only possible to send a report when a client is open? we have a customer who wants reports automatically generated and in their email every month and does not wish to use a client. is this still impossible?

No, reporting now "lives" in the Gateway. You no longer need a Vision Client open.

1 Like