6689
Views
11
Comments
How do we include a chart in an email body?
Discussion
Hi there,

I have a requirement to send an email daily to managers in our organisation, and the body content of the email must contain a chart showing time worked by each employee team.

When I add a RichWidgets/Chart web block to the Email interface the chart does not display. When the email is sent it does not include any chart information either.

Please could you advise how I can insert a chart into the body of an email that is sent by OutSystems.

Please note that the requirement is that the chart is visible in the email HTML and not as an attachment to the email which requires an additional action to view.

Many thanks,
Rob
2012-10-08 11-59-27
Guilherme Pereira
Staff
Hi Rob,

As an actual HTML in the body I dont think is possible (the charting library uses javascript) and your mail client wouldn't probably run it anyway.

To solve a similar requirement in the past what I did was to create a page that renders the chart and then use another that takes a screenshot of that page and returns the image.

On the email body I used an image with an ExternalUrl that would point to the second page and thus the image would be on the email (not as HTML but as an image).

Hope this helps.

Cheers
Guilherme
2018-05-31 18-44-19
Ravi Vakkalanka

Guilherme Pereira wrote:

Hi Guilherme,

Could you please let me know how did you get the screenshot in another page and save it as an image on the server ? 


Hi Rob,

As an actual HTML in the body I dont think is possible (the charting library uses javascript) and your mail client wouldn't probably run it anyway.

To solve a similar requirement in the past what I did was to create a page that renders the chart and then use another that takes a screenshot of that page and returns the image.

On the email body I used an image with an ExternalUrl that would point to the second page and thus the image would be on the email (not as HTML but as an image).

Hope this helps.

Cheers
Guilherme



2024-09-14 05-42-00
Ozan Can Çalı
Champion

Guilherme Pereira wrote:

Hi Rob,

As an actual HTML in the body I dont think is possible (the charting library uses javascript) and your mail client wouldn't probably run it anyway.

To solve a similar requirement in the past what I did was to create a page that renders the chart and then use another that takes a screenshot of that page and returns the image.

On the email body I used an image with an ExternalUrl that would point to the second page and thus the image would be on the email (not as HTML but as an image).

Hope this helps.

Cheers
Guilherme

Hi Guilherme,

This is an old post of yours but I was wondering how you did that, especially the "...and then use another that takes a screenshot of that page and returns the image" part. I currently use HtmlToPdfConverter and need pdf output.

Thanks a lot!

UserImage.jpg
Rob Seagram
Thanks Guilherme,

I appreciate your feedback. I guess it makes sense because of the javascript requirement for the charts. I will try the approach you have used before.

Many thanks.
Kind regards,
Rob
UserImage.jpg
Kimberly Parker
Rob Seagram wrote:
Hi there,

I have a requirement to send an email daily to managers in our organisation, and the body content of the email must contain a chart showing time worked by each employee team.

When I add a RichWidgets/Chart web block to the Email interface the chart does not display. When the email is sent it does not include any chart information either.

Please could you advise how I can insert a chart into the body of an email that is sent by OutSystems.

Please note that the requirement is that the chart is visible in the email HTML and not as an attachment to the email which requires an additional action to view.

Many thanks,
Rob
 A HTML5 chart may work but I am quite doubtful as most of the client have SVG blocked. But still you can check out for HTML5 chart.
 
2012-08-01 17-33-40
Gerry

See if there's a way to output it as an image.
2012-10-08 11-59-27
Guilherme Pereira
Staff

Hi Ravi,


The component has a generatepdf and a generateimage. This last one receives a url and returns the binary of the image which you can store on the db and include in your email.


Hope this helps,

Guilherme

2018-05-31 18-44-19
Ravi Vakkalanka

Thank you for your response. I am getting Access denied error when trying to generate image.

2012-10-08 11-59-27
Guilherme Pereira
Staff

Hi Ravi,


You're trying in debug mode when you try it in runtime do you get the same error?

You seem to be using a personal environment. What is the url you're using on the generate image?

I recommend you looking at the FAQ and double check your configuration. After that use the FAQ guidance to troubleshoot what the problem might be,


Thanks,

Guilherme

2012-10-08 11-59-27
Guilherme Pereira
Staff

Hi Ozan, 


At the time I didn't use Html2Pdf because if i recall correctly it din't work for screenshots (Generate image was not present I think) or was done in an older version of the platform. So the solution was completely done in .NET.


If it was today I'd probably use the same solution you have and use Html2Pdf for that.


Cheers,

Guilherme

2024-09-14 05-42-00
Ozan Can Çalı
Champion

Guilherme Pereira wrote:

Hi Ozan, 


At the time I didn't use Html2Pdf because if i recall correctly it din't work for screenshots (Generate image was not present I think) or was done in an older version of the platform. So the solution was completely done in .NET.


If it was today I'd probably use the same solution you have and use Html2Pdf for that.


Cheers,

Guilherme


Thanks Guilherme. I guess Html2Pdf is not enough for rendering pages with JS. HighCharts uses a lot of JS, so I had to use PhantomJS with a wrapper .NET class. 

Thank you for your help.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.