我正在尝试使用 Apps 脚本在电子邮件中嵌入预填写的表单。这些电子邮件只会发送给 Gmail 用户。我想要的功能与手动通过电子邮件发送表单时按“在电子邮件中包含表单”选项相同。
我已经成功创建了prefilledUrl
并使用UrlFetchApp
and HtmlService
从表单中获取 Html 并发送电子邮件。
But when it arrives it looks like the screenshot below and user can not submit.
![Screenshot of form embedded in email](https://i.stack.imgur.com/j69pE.png)
我正在使用的代码的精简版本如下:
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
});
无论如何,是否可以将表单嵌入到电子邮件中,就像选择“在电子邮件中包含表单”(如下面的屏幕截图所示)时一样?
![enter image description here](https://i.stack.imgur.com/C1YJl.png)
- 将表格连同电子邮件中包含的表格一起发送给您自己。
- Open Gmail in the browser, press F12. Find the div of the form in the email body.
- 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.
- Send the email with the above HTML file, you should be able to get a similar result as below.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)