使用Apps脚本将Google Form嵌入Gmail中 [英] Embed Google Form in Gmail using Apps Script

查看:87
本文介绍了使用Apps脚本将Google Form嵌入Gmail中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Apps脚本在电子邮件中嵌入预填写的表单.电子邮件将仅发送给Gmail用户.我想要的功能与手动通过电子邮件发送表单时按在电子邮件中包含表单"选项相同.

I'm trying to use Apps script to embed a prefilled Form in an email. The emails will only be sent to Gmail users. I want something that works the same as pressing the 'include form in email' option when manually emailing a form.

我已经成功创建了prefilledUrl,并使用UrlFetchAppHtmlService从表单获取HTML并发送电子邮件.

I've successfully created the prefilledUrl and used UrlFetchApp and HtmlService to get the Html from the form and send email.

但是到达后,看起来就像下面的屏幕截图,用户无法提交.

But when it arrives it looks like the screenshot below and user can not submit.

我正在使用的代码的精简版本如下:

A stripped down version of the code I am using is the following:

var prefilledForm = 'prefilledForm link here');
Logger.log(prefilledForm);

var subject = 'Message from Office';
var response = UrlFetchApp.fetch(prefilledForm);
var htmlBody = HtmlService.createHtmlOutput(response).getContent();

var body = 'Dear '+mName+',\n\n'+mMessage+'\nPlease acknowledge by submitting the form below.\nRegards,\nSchool Office';

GmailApp.sendEmail(eEmail,subject,body,{
  noReply:true,
  htmlBody: htmlBody
});

是否像在下面的屏幕快照中选择在电子邮件中包括表单"一样,将表单嵌入到电子邮件中?

Is there anyway to embed the form in an email just like it does when you select 'include form in email' like the screenshot below?

推荐答案

  1. 使用电子邮件中包含的表格将表格发送给自己.
  2. 在浏览器中打开Gmail,然后按F12.在电子邮件正文中找到表单的div.
  3. 将div代码粘贴到Apps脚本HTML文件的正文中.或将其粘贴到您脚本中的HTML正文电子邮件中,但我没有对其进行测试.
  4. 发送带有上述HTML文件的电子邮件,您应该能够获得类似的结果,如下所示.
  1. Send the form to yourself with the form included in the email.
  2. Open Gmail in the browser, press F12. Find the div of the form in the email body.
  3. Paste the div code to the body of the Apps Script HTML file. Or paste it to email HTML body in your script, I didn't test it.
  4. Send the email with the above HTML file, you should be able to get a similar result as below.

这篇关于使用Apps脚本将Google Form嵌入Gmail中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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