Decoding & Setting Up Image Display in Template

Decoding & Setting Up Image Display in Template

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

Related : Send Email using Templates via applications.

Descriptions:

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.

Syntax:

<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.name} <${object.hr_id.work_email}>]]></field>

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

<field name=”subject”>Happy Birthday ${object.name}</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 ${object.name},</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;”>

<p>

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

</p>

</div>]]>

</field>

</record>

 

For Customized ERP Solutions at best prices Contact Us now