SendGrid:使用SendGrid时如何将表单嵌入HTML模板邮件中

问题描述 投票:0回答:1

我正在构建一个将通过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
1个回答
0
投票

您不能使用<iframe>嵌入Google表单(或任何表单)。

某些电子邮件客户端根本不接受表单,或者如果它们完全呈现,则功能有限,但是Google表单具有可从其平台使用的嵌入功能。

本质上,在Google表单上:

  1. 填写表格
  2. 点击“发送”
  3. 插入您自己的Gmail地址-这仅仅是为了获得代码
  4. 在“发送方式”下,选择“电子邮件”
  5. 勾选'在电子邮件中包含表格'

请参见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而不是通过电子邮件填写表格的人使用,因为会有一些无法使用的电子邮件客户端。

© www.soinside.com 2019 - 2024. All rights reserved.