我可以在SendGrid模板中使用带有替换标签的图像吗? [英] Can I have an image with a substitution tag in a SendGrid template?

查看:124
本文介绍了我可以在SendGrid模板中使用带有替换标签的图像吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在SendGrid中创建一个模板,并试图将图像和URL放置在中间,我希望将其作为标签,以便可以动态替换我的代码,因为它将来自我的数据库.

I am creating a template in SendGrid and I was trying to put an image in the center, and the URL I would like to be a tag so I can substitute dynamically in my code, because it will come from my database.

我试图简单地在输入字段中放置标签,但是它不接受. 我有办法做到吗?

I tried to simply place a tag in the input field, but it doesn't accept that. Is there a way I can accomplish that?

谢谢!

推荐答案

我假定您已通过Node.js设法触发了SendGrid API,因为您正在使用Express标记来标记问题.

I assume that you have managed to trigger the SendGrid API via Node.js, since you're tagging the question with the Express tag.

我目前也在尝试使用SendGrid构建事务性电子邮件模板,而我设法做到了这一点.

I'm currently trying to build transactional email template using SendGrid as well, and I managed to accomplish this.

您可能想先使用构建器添加新的图像元素.

You'd probably want to add a new image element first using the builder.

然后上传图像.上载图像后,双击图像元素.抓取图像文件的名称并复制.

Then upload an image. Once your image is uploaded, double click on the image element. Grab the name of your image file and copy it.

切换到代码视图.

在代码视图中,找到包含您的图像文件名称的html标记.这是我的例子.

In the code view, find the html tag that contains your name of your image file. Here's an example in my case.

将此代码替换为您的替换标签".

Replace this code with your "substitution tag".

保存模板.您的模板应该可以使用了.在您的Node.js代码中,设置替换标记.

Save the template. Your template should be ready to use. In your Node.js code, set the substitution tag.

mail.personalizations[0].addSubstitution(new helper.Substitution("your-subtitution-tag", "image-url"));

我使用了这个库: https://github.com/sendgrid/sendgrid-nodejs 希望您的电子邮件中应包含新图像.

I used this library: https://github.com/sendgrid/sendgrid-nodejs Hopefully your email should contain the new image.

我模糊了上面的一些敏感内容.这是我的电子邮件结果.希望这会有所帮助!

I blurred out some sensitive contents above. This is the email result on my end. Hope this helps!

这篇关于我可以在SendGrid模板中使用带有替换标签的图像吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆