This code worked fine in 8.1, but now I get PDFs I can’t open. Or JPEGs or PNGs.
In the code below, I am creating a PDF byte array from system.report.executeReport(). For troubleshooting, I am also saving the file as a PDF.
reportResult = system.report.executeReport(
path=reportName,
project = projectName,
parameters = params,
fileType = "pdf")
system.file.writeFile(r"E:\Downloads\Projects\ReportTest\testfile.pdf", reportResult)
system.net.sendEmail(
fromAddr = "Press10Site@customer.com",
subject = "Press 10 Site Alarm Frequency Report",
to = toList,
html = False,
body = "File type = {0}".format(type(reportResult)),
attachmentNames = ["MyFile.pdf"],
attachmentData = [reportResult],
smtpProfile = "customerSMTP"
)
When I get the email, the “pdf” file attached gives me this:

Meanwhile, the file that was saved gives me a good pdf file. Likewise, using the Report’s integral email scheduler, I get the same good PDF file.
Because I can save the file and open as PDF, I know it isn’t the report.executeReport() that is going wrong.
Because I can email the file from other IGN utilities (Report’s Integral Scheduler), I don’t think my company’s email, or the customer’s company’s email are doing bad things to attachments.
That would seem to leave system.net.sendEmail() as the prime suspect, I’m afraid. I reiterate: this is code I have been using in 8.1 that has worked well and this is my first time working on 8.3, though I did not see any real changes to net.sendEmail from 8.1 to 8.3 in the docs.
Caveat: I am a good try-er, but this GW is owned by the customer and they have their own dedicated and competent team of IGN managers, and therefore they have the final say over any testing that would require admin access.
Anyone else experience this? Any ideas?