odoo17 email 模版配置css样式
时间: 2025-05-25 20:02:10 浏览: 13
### Odoo 17 Email Template CSS Styling Configuration
In Odoo 17, configuring CSS styles for email templates allows customization of the appearance to match brand guidelines or specific design requirements. The process involves several key steps and considerations.
To apply custom CSS within an email template in Odoo:
The `<style>` tag can be included directly inside the header section of the email body using QWeb templating language[^1]. This ensures that all defined styles are applied consistently across different email clients which may strip out external stylesheet links due to security policies.
For example, a simple way to add inline CSS is as follows:
```xml
<template id="email_template_example" inherit_id="mail.mail_notification_light">
<field name="body_html">
<![CDATA[
<div style="font-family: Arial; color: #3498db;">
<p>Dear ${object.name},</p>
<p>This is your personalized message.</p>
</div>
]]>
</field>
</template>
```
Alternatively, embedding more complex stylesheets requires wrapping them within a `<t t-call="web.external_layout">` directive followed by placing the entire set of rules between opening and closing `<style type="text/css">...</style>` tags before any HTML content appears.
```xml
<t t-name="custom_email_styles">
<t t-call="web.external_layout">
<t t-set="head">
<style type="text/css">
.main-content {
background-color: #f0f0f0;
padding: 20px;
}
h1.title {
font-size: 2em;
text-align: center;
}
p.paragraph-text {
line-height: 1.6;
}
</style>
</t>
<div class="main-content">
<!-- Your email content here -->
</div>
</t>
</t>
```
Testing thoroughly with various email providers remains crucial since not all support identical features when rendering emails.
阅读全文
相关推荐


















