Send HTML-formatted emails in Odoo 18 (instead of webhooks for Microsoft Teams) 🚀

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 webhook to post a message directly to Microsoft Teams. However, it turned out that webhooks from Odoo 18 are not compatible with Microsoft Teams.

The solution: Send an email to a Teams channel. This method has a few prerequisites:

  • The e-mail must be sent to the Microsoft Teams channel address.
  • 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 in Odoo: the Odoo support user who sends the emails was integrated into the Microsoft team.

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-rawIs used if HTML content is to be rendered directly (e.g. for object.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 via an email instead of a webhook. If you need support with the setup, please contact us at Olbricht IT!

Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

Was this article helpful?

Related Articles

Leave A Comment?