【发布时间】:2020-03-23 16:08:38
【问题描述】:
我正在构建一个可以通过 SendGrid 发送 HTML 模板邮件的应用程序。
现在,我想在 HTML 模板邮件中嵌入一个 Google 表单,以发送带有嵌入 Google 表单的电子邮件。
我的 HTML 模板是一个字符串,
基本上是这样的,
const emailHTML = `
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html data-editor-version="2" class="sg-campaigns" xmlns="http://www.w3.org/1999/xhtml">
<head>
.....
</head>
<body>
....
<iframe src=“https://docs.google.com/forms/d/e/.../viewform?embedded=true” width=“640" height=“1493” frameborder=“0" marginheight=“0” marginwidth=“0">Link</iframe>
</body>
</html>
`
然后我会将这个 HTML 字符串作为 html 变量传递给 SendGrid API,
router.post('/send-email', (req, res) => {
const { recipient, sender, topic, text, emailHTML } = req.body;
const msg = {
to: recipient,
from: sender,
subject: topic,
text: text,
html: emailHTML
}
sgMail.send(msg).then((msg) => {
res.json({ Message: msg })
});
})
我测试了我收到的电子邮件,但没有看到电子邮件中嵌入的 Google 表单。
如何将 Google 表单嵌入 HTML 模板邮件以通过 SendGrid 发送?
【问题讨论】:
标签: javascript html html-email sendgrid