如何解决动态模板中的SendGrid动态颜色
是否可以使用SendGrid的动态模板指定文本的颜色?
示例: 我正在通过SendGrid Python API传递动态变量
- 如果变量是负整数,则将颜色设为Red
- 如果变量是正整数,则使color = Green
动态模板Python文档: https://github.com/sendgrid/sendgrid-python/blob/main/use_cases/transactional_templates.md
import json
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
message = Mail(
from_email='from_email@example.com',to_emails='to@example.com',html_content='<strong>and easy to do anywhere,even with Python</strong>')
message.dynamic_template_data = {
'subject': 'Testing Templates','name': 'Some One','city': 'Denver'
}
message.template_id = 'd-f43daeeaef504760851f727007e0b5d0'
try:
sendgrid_client = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sendgrid_client.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
print(e.message)```
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。