提取html后,使用MailApp发送表单.将Google表单嵌入到电子邮件中.生成的电子邮件仅包含文本 [英] Send Form with MailApp after fetching html. Embed Google Form into email. Generated email contains only text

查看:131
本文介绍了提取html后,使用MailApp发送表单.将Google表单嵌入到电子邮件中.生成的电子邮件仅包含文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Google表单嵌入电子邮件中,并通过MailApp发送.我正在尝试使用位于以下位置的代码: https://stackoverflow.com/a/23671529/4305236 :

I want to embed a Google form in an email and send it with MailApp. I'm attempting to use code found at: https://stackoverflow.com/a/23671529/4305236:

var form = FormApp.create('New Form');
....
var url = form.getPublishedUrl();
var response = UrlFetchApp.fetch(url);
var htmlBody = HtmlService.createHtmlOutput(response).getContent();
    MailApp.sendEmail({
    to: email,
    subject: subject,
    htmlBody: htmlBody,
  });
...

日志显示表单的所有html.

The logs show all the html for the form.

但是,当我运行代码时,电子邮件就像文本一样,链接位于底部.但是,当我在电子邮件中显示原始邮件"时,表单的所有html似乎都在那里,就像在日志中一样.

However, when I run the code, the email just looks like text, with the links at bottom. When I "show original" in the email, though, all that html for the form seems to be there, like in the log...

非常感谢您的帮助.

生成的表单是什么样的,希望将其嵌入到电子邮件中:

相反,他们得到了什么:

推荐答案

在这里回答: https://stackoverflow.com/a/60749897/3383907 .

出于历史记录目的复制/粘贴:

Copy/pasting for history purposes:

当Google直接将表单发送给人们并将表单嵌入到电子邮件中时,他们将使用他们的新产品AMP.您可以在此处了解更多信息:

When Google sends the form to folks directly and embeds the form in the email they are using their new offering called AMP. You can read more about it here:

  • https://developers.google.com/amp/
  • https://www.blog.google/products/g-suite/bringing-power-amp-gmail/
  • https://developers.google.com/gmail/ampemail/

您正在使用的代码获取表单的原始HTML,就像在浏览器中为用户呈现的那样.该代码不是AMP格式.因此,它不会做您想要的事情.

The code you're using gets the raw HTML of the form as it would be rendered for a user in a browser. This code is not in AMP format. Ergo it will not do what you want.

如果您希望获得AMP的经验,则需要自己创建AMP电子邮件.

If you want that AMP experience you will need to create the AMP email yourself.

我不认为 FormApp 具有编程方式将表单发送给人们,就像您可以从 https://docs.google.com/forms/.

我希望能帮上忙.

这篇关于提取html后,使用MailApp发送表单.将Google表单嵌入到电子邮件中.生成的电子邮件仅包含文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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