SendGrid

编程入门 行业动态 更新时间:2024-10-27 19:22:20
SendGrid-csharp - 模板引擎 - 汉字(SendGrid-csharp - Template Engine - Chinese Characters)

有没有人知道如何在SendGrid提供的模板引擎中使用中文字符(或任何其他特殊字符)? 我在主题,html和文本属性中插入中文字符没有问题,它们都没问题,但是当我尝试使用AddSubsitute和EnableTempalteengine时,所有结果(测试我收到的电子邮件)将是一堆奇怪的字符。

Does anyone know how to use Chinese characters (or any other special characters) in the template engine provided by SendGrid? I have no problem plugin Chinese characters in subject, html and text properties, they all turn out okay, but when I tried to use AddSubsitute and EnableTempalteengine, all the result (testing email I received) will be bunch of weird characters.

最满意答案

SendGrid模板引擎支持unicode(包括中文字符)。 但是,要使用它们,您需要在将它们发送到SendGrid之前将它们转义。 SendGrid寻找的转义格式是Javascript Unicode Escaping,因为它是一个JSON对象(例如\u4F60\u597D\u4E16\u754C )。

要使用模板引擎发送替换,您将拥有类似于以下内容的SMTP API参数 :

{ "to" : ["nick@sendgrid.com"], "sub" : { "-test-" : [ "\u4F60\u597D\u4E16\u754C" ] }, "filters": { "templates": { "settings": { "enabled": 1, "template_id": "5997fcf6-2b9f-484d-acd5-7e9a99f0dc1f" } } } }

The SendGrid Template Engine does support unicode (including Chinese characters). To use these however, you'll need to escape them prior to sending them to SendGrid. The escape format SendGrid looks for is Javascript Unicode Escaping as it's a JSON object (e.g. \u4F60\u597D\u4E16\u754C).

To send a substitution with the template engine, you would have an SMTP API parameter something like the followin:

{ "to" : ["nick@sendgrid.com"], "sub" : { "-test-" : [ "\u4F60\u597D\u4E16\u754C" ] }, "filters": { "templates": { "settings": { "enabled": 1, "template_id": "5997fcf6-2b9f-484d-acd5-7e9a99f0dc1f" } } } }

更多推荐

本文发布于:2023-08-03 06:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1384141.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SendGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!