Send HTML-formatted e-mails in Odoo 18
In Odoo 18, email templates can be formatted with HTML to send professionally designed emails. This is particularly useful if automatic notifications or structured emails, such as support tickets, are to be sent.
Application example: VIP customers & SLA notification
In our support process, we realized that it is important to quickly notify the team about VIP customers or tickets with a certain SLA level. The original idea was to use a webhookEin Webhook ist eine Methode zur automatisierten Kommunikation zwischen zwei Anwendungen in Echtzeit. Er ermöglicht es einer Anwendung, Daten oder Ereignisse an eine andere Anwendung zu senden, sobald eine bestimmte Aktion ausgeführt wird. Statt dass eine Anwendung regelmäßig Daten abfragt (Polling), sendet der Webhook automatisch eine Nachricht oder eine HTTP-Anfrage an eine vordefinierte URL, sobald ein Ereignis eintritt. Anwendungsbeispiel: In... mehr erfahren to post a message directly to Microsoft Teams
The solution: Send an email to a Teams
- The e-mail must be sent to the Microsoft Teams
- The sender must be at least a member of the team for the message to be put through.
- However, this was not a problem thanks to the integration of Exchange

Step 1: Create e-mail template in Odoo 18
In Odoo, go to Settings > Technical settings > Email templates and create a new template. Select the appropriate model, e.g. customer service ticket.

Step 2: Insert HTML code for the e-mail
The HTML code is inserted directly into the email template in the language selection (DE/EN for us). This allows you to design different content for different languages.
Here is an example of a ticket notification:
<p>🚀 <b>Neues VIP-Ticket erstellt!</b></p>
<p><b>Betreff:</b> <t t-esc="object.name"/></p>
<p><b>Kunde:</b> <t t-esc="object.partner_id.name if object.partner_id else 'Unbekannt'"/></p>
<p><b>Priorität:</b> <t t-esc="object.priority"/></p>
<p><b>Zuständig:</b> <t t-esc="object.user_id.name if object.user_id else 'Nicht zugewiesen'"/></p>
<hr>
<t t-if="object.body">
<p><t t-raw="object.body"/></p>
</t>
<p>
<a t-att-href="'https://deine-ODOO-URL/web#id=' + str(object.id) + '&model=helpdesk.ticket'">🔗 Kundendienstticket ansehen</a>
</p>
Step 3: Test the e-mail preview
Save the template and use the preview function to check whether the data is displayed correctly.

How do the variables in the email template work?
In Odoo templates, variables are integrated with t-esc
or t-raw
:
t-esc
: Ensures that the value is output securely (no HTML injection possible).t-raw
Is used if HTML content is to be rendered directly (e.g. forobject.body
).
You can find the official documentation for Odoo 18 here: Odoo 18 e-mail templates.
Conclusion
With HTML-formatted email templates in Odoo 18, you can send professionally designed messages and easily notify Microsoft Teams
Ein Webhook ist eine Methode zur automatisierten Kommunikation zwischen zwei Anwendungen in Echtzeit. Er ermöglicht es einer Anwendung, Daten oder Ereignisse an eine andere Anwendung zu senden, sobald eine bestimmte Aktion ausgeführt wird. Statt dass eine Anwendung regelmäßig Daten abfragt (Polling), sendet der Webhook automatisch eine Nachricht oder eine HTTP-Anfrage an eine vordefinierte URL, sobald ein Ereignis eintritt. Anwendungsbeispiel: In... mehr erfahren. If you need support with the setup, please contact us at Olbricht IT!
Dieser Beitrag ist auch verfügbar auf:
Deutsch (German)
Leave A Comment?