我正在构建一个将通过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发送?
您不能使用<iframe>
嵌入Google表单(或任何表单)。
某些电子邮件客户端根本不接受表单,或者如果它们完全呈现,则功能有限,但是Google表单具有可从其平台使用的嵌入功能。
本质上,在Google表单上:
请参见https://www.maketecheasier.com/embed-google-forms-in-email/以获取完整说明。
现在,要获取要插入到SendGrid中的实际代码,您必须从该电子邮件中获取表单的源代码,并将其粘贴到SendGrid电子邮件的HTML中。
基本上是
在Gmail中打开电子邮件单击更多(右上角的下拉箭头)->显示原始复制相关代码
请参见https://gillandrews.com/embed-a-survey-in-email-newsletter-google-forms/以获取完整说明。
我还将在其中添加一个链接,供那些希望直接在Google而不是通过电子邮件填写表格的人使用,因为会有一些无法使用的电子邮件客户端。