Email Templates - Attach charts/images in email body



  • I have been exploring the email template capabilities and encountered a scenario where I needed to attach a chart/image to the email body.
    I created a template with the HTML recipe, which allowed me to attach plain HTML (without any images/charts) to the email body.

    However, when I included an image, it did not appear in the email body.
    I also tried using the html-with-browser-client recipe and converted the response to HTML content using res.content.toString('utf-8'), but the image still did not appear.

    Could you suggest how I can achieve this? Additionally, if you have any references, please provide them.



  • This means you call jsreport API, get back HTML, and then use some library to send an email, but the received email doesn't show images? This is more a topic for the particular library you use.



  • This means you call jsreport API, get back HTML, and then use some library to send an email, but the received email doesn't show images? Yes, you are correct.
    We have configured nodemailer library with gmail SMTP.

    Currently, the html template generates the base64 format for the images using dataURI notation. is it possible to generate the CID notation?



  • It is up to you how you code it....

    You can for example use string replace in the html to replace datauri with CID in the afterRender script.

    Or read the images in the afterRender script like this https://jsreport.net/learn/assets#read-asset


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.