Embed Image (chart) in HTMLMail with mail binding

I try to create a HTML-Mail with openhab and mail binding.

Most things working. But one Problem I didn’t find a solution until now:

Ich want to have a chart from openhab directly within the html mail (not as an attachment).

But how do I code this with openhab?

Not, sure, but somewhere I read I would have to reading the image, code it with Base64 and integrate it in the header?

Would that work? Anybody can help with some rows of code i can integrate?

As far as I understand the mail binding it just offers the possibility to attach an image to a html mail. The bas64 image would not have to be included in the header but as part of the mail body. The header needs to contain information as well. See e.g. embedding image in html email - Stack Overflow

In case you want to send a mail with inline image(s) you can do that e.g. by running a shell script, using perl or python modules. To do that start that script from within the exec binding or executeCommandLine.

For an example how to send html mail with inline image using python you may have a look at

Related -

Thanks for answer.AsI read, cid is deprecated and images need to be encoded in multipart header of the mail. Because the most parts of the mail are dynamicly coming from item.states, I have some problems doing this in python on base of your example. But maybe that will help me do understand and find a solution

Thank you Rossko, but that thread I already looked will put the images as an attachment, not adressable within the html part of a mail as I know.

Is there a way with the mail binding to create a mime multipart E-Mail under control of additional header fields?

That is e.g. item over time ? I think the thread @rossko57 pointed to shows a possibility how to get the charts into an image ( screenshot ). Then it can be included in the mail.

May I kindly ask where your got this info from ? I checked several RFCs but was not able to find that info.

Hello Wolfgang,

you are right: CID still active. I read so much last few days. So embedded base64-Data directly within html-image-tag is not supported by every OS or mail-Programm, but CID still is actual.

The linked thread from rossko I looked also. But there i only found how to save html pages in an image and attach them. thats not my problem.

I try to create a html mail, with tables, different images, charts, etc… Of course I could referece with img to external http-sources for the images. Then I got a pretty nice mail.

But to send the images within the mail (embedded, so linkable directly in html code) not as an attachment, I need to get them in the header of the E-Mail.

So if not possible with rules and mail binding directly, I need to get deeper in your example to write the full rule in python.

The HTML Mail should include about 40-50 different state values and calculations, and I’m not familiar until now how to do that in Python. But seems I need to learn it.