Subject : Display Images in Email (send using Templates).

Related : Send Email using Templates via applications.


We can send email using email template to the custom. That time suppose we have company logo then we would like to image display  logo in email. Sometimes image will not show in email or display in broken format.

For that, we have to use python base64 decoder to decode the images and display on template.


<img src=”data:image/png;base64,${object.company_id.logo}” />

For Example:

Following in file.xml for Email Template,

This will send email via template to wish Birthday and birthday image will take from the current model record.

Like, Field  birthday_image  stores a image for person. Then take from this fields and decode using pyton base64 then display image on mail.

<record id=”mail_template_1″ model=”mail.template”>

<field name=”model_id”  ref=”model_hr_employee”></field>

<field name=”name”>Birthday Mail</field>

<field name=”email_from”><![CDATA[${} <${object.hr_id.work_email}>]]></field>

<field name=”email_to”><![CDATA[${} <${object.work_email}>]]></field>

<field name=”subject”>Happy Birthday ${}</field>

<field name=”auto_delete” eval=”True”/>

<field name=”body_html”><![CDATA[

<div style=”font-family: ‘Bleeding Cowboys’, Ubuntu ;font-type: Italic; font-size: 50px; color:#e1e001; “>

<p>Hello ${},</p>

<p>May your birthday be the window which opens a million vistas

that helps you in the fulfilment of your dreams & accomplishments of your goals!</p></div>

<div style=”font-family: ‘Bleeding Cowboys’, Ubuntu ;font-type: Italic; font-size: 50px; color:#e1e001;text-align: center;”>

<p>Wish you a very Happy Birthday!!</p>

<div style=”text-align: center;”>


<img src=”data:image/png;base64,${object.birthday_image)image_medium.image}” style=”width: 150px;height: 180px;” />






For Customized ERP Solutions at best prices Contact Us now