Capture Newman Output and Include in Email Body

Hi,

I’m able to use the HTML Extra Reporter to capture our test’s results.

I then compress it and send it as an email.

This would mean that the recipient will get the ZIP file and will need to open the attachment first before getting into the actual report.

Thus, I’m thinking if I can include the number failures in the email body itself, so if there’s none, the recipient can focus on opening the attachments with failures.

image

Has anyone tried this? My script runs on PowerShell if it matters.

This isn’t really a Postman query if you are using PowerShell to send the email.

In your PowerShell script, you will need to import and parse the HTML report and target those elements so you can use them in your email template (before the code to compress the report).

I know a fair bit about PowerShell, but I’ve never had to work with HTML files before so I can’t tell you exactly how to parse the file (like I could if it was an CSV extract).

Couldn’t you just send the whole email as HTML, and not compress it?

Hi Mike,

Agree, was wondering if someone has done something similar before in the community.

I’ve tried sending the HTML content within the body and it shows as follows in Outlook:

image

If I view via web browser:

image

If I copy the raw message source and paste it to an HTML viewer, it’s able to view the report.

All I can recommend is to Google “powershell parse html” and have a look at some of the responses.

Reading a local HTML file can cause issues, but there are examples that might be of use for you.

Hi @michaelderekjones ,

Finally got it to work by using the JSON reporter instead and using JSONPath to extract the values I want.

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.