HTML Report inside body of email

Is it possible, and are there scripting examples, to create an emailed HTML report with the report in body of the email instead of as an attachment?

I would expect that you would need to use system.report.executeReport() with a return type of HTML. That will give you a byte array that you can turn into a string, and then add that to the body of an email you send via system.net.sendEmail()

Thanks. Do you know how to read it as a string and preserve the HTML formatting? When I use the following code it just puts all the text and numbers from the report into one long string.

settings = {“path”:“C:\IgnTemp”, “fileName”:fileName, “format”:“html”}
system.report.executeAndDistribute(path=“HTML Report”, project=“zz_Sandbox”)

Report = “C:\IgnTemp\” + fileName
ReportData.append(system.file.readFileAsBytes(Report))
body += (system.file.readFileAsString(Report))

Ugh, I forgot that with the changes in reporting we made a few years ago, HTML reports are now effectively multiple files. To make it worse, the HTML file itself already includes body tags, which I think will mess you up.

I suppose I should back up and find out what your end goal really is. Does the report have to be HTML, or is just including the report inline good enough?

I have a report that I run for a couple dozen locations, that all get sent out in a single email as PDF attachments.

I would like to get rid of the multiple attachments.

I wasn’t very encouraged looking into combining the PDFs into a single PDF to attach, so I was hoping I could build HTML reports and just keep appending them to the body of the email.

Sorry to bump an old topic, but I'm interested in mailing a nicely formatted report to users in a way that they can read directly without having to open/save an attachment, and preferably still be able to copy table date (i.e. no converting the whole thing to an inline image).

I used a "run script" action on my report with this in it, which minimally works, but all the formatting is lost:

report_html = reportBytes.tostring().decode('utf-8')
system.net.sendEmail(smtpProfile='mail_profile', fromAddr='alice@test.com', 
	subject='HTML Test', body=report_html, html=True, to=['bob@test.com'])

Since this thread was covering the exact same topic and never really came to a conclusion, I figured it was worth asking here.

Do you have any suggestions?

The reporting engine we use can only produce a few formats – basically something that’s an image (pdf or png) or something that’s essentially raw data (csv, excel). If you want nicely formatted, you need to use the image or create your own HTML table from the “raw” data.

[edit] Yes, there’s an HTML format, but I wouldn’t call it “nice” :slight_smile: