0

I need to send an automation test result with mail content as Pie chart using java. Am wasting almost half day for this, anyone can help on this. Thanks in advance.

Thangaraj
  • 257
  • 3
  • 13
  • You could try using a "inline" image approach, using a multipart mime content - as demonstrated in [Inline images in email using JavaMail](https://stackoverflow.com/questions/2996514/inline-images-in-email-using-javamail) – MadProgrammer May 10 '18 at 04:36
  • I want to send, mail with the following link contains chart https://www.w3schools.com/howto/tryit.asp?filename=tryhow_google_pie_chart – Thangaraj May 11 '18 at 07:06

1 Answers1

0

You can send chart image in html view by using inline image approach. You need to declare your images like this :

<img src="imagepath" />

Load images as MimeBodyPart and match imagepath with the FileName of the MimeBodyPart.

Edited Part

For sending html view using JS in email, you need something like:

 StringWriter writer = new StringWriter();
 IOUtils.copy(new FileInputStream(new File("home.html")), writer);

 message.setContent(writer.toString(), "text/html");
S. M. Mohiuddin
  • 378
  • 3
  • 10
  • Thaks Mohiuddin, Actually the chart is not an image format it is in HTML file with javascript. We know can send mail with plain HTML but my case I need to send mail with some javascript code(for loading chart dynamically) – Thangaraj May 10 '18 at 04:56
  • Please see the edited part to send html page in email – S. M. Mohiuddin May 10 '18 at 05:02
  • That code also not working. Please find the below link source code, and I need to send that output chart to mail. https://www.w3schools.com/howto/tryit.asp?filename=tryhow_google_pie_chart – Thangaraj May 10 '18 at 05:11
  • Do you have any solution for sending the chart(refer previous comments link) to mail – Thangaraj May 11 '18 at 07:07