如何访问或调用“将此表格发送给他人"? [英] How to access or call "Send this form to others"?

查看:20
本文介绍了如何访问或调用“将此表格发送给他人"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个附加到 Google Apps 电子表格的表单.这是一种让我的同事向我们的每周审查会议提交议程项目的表格.我正在编写一个脚本来自动通过电子邮件向相关人员发送提醒.

I have a form attached to a Google Apps spreadsheet. It's a form to let my coworkers submit agenda items to our weekly review meeting. I'm writing a script to automatically email a reminder to the relevant people.

让它不那么烦人&对他们来说很乏味,我想在电子邮件中实际嵌入表单.Google Docs 提供了一种手动发送表单的方法:电子表格 > 表单 > 发送表单.但是,我在 Google Apps Scripts 文档中找不到任何可以触发此功能的方法,例如

To make it less annoying & tedious for them, I'd like to actually embed the form within the email. Google Docs provides a way to manually send a form: Spreadsheet > Form > Send form. However, I can't find any way in the Google Apps Scripts documentation that lets me trigger this functionality, e.g.

  • 类似于 sendFormInEmail 的方法
  • 访问电子邮件友好表单 HTML,我可以将其分配给 的 htmlBody 参数sendEmail 方法.
  • 触发 Google Apps 中的任意菜单项
  • 还有别的吗?

我可以通过从电子邮件中提取生成的 HTML 并将其指定为 htmlBody 参数来解决此问题,但是每次我们想要对表单进行更改时,我都必须手动更新 html —— 不是什么我想发生.

I could do a workaround by extracting the generated HTML from an email and assigning it as the htmlBody argument, but then I'd have to manually update the html every time we want to make a change to the form -- not what I want to happen.

有什么建议吗?

推荐答案

Joris,你说得对.您可以使用 fetch() 方法将表单的 html 发送到用户的邮箱:

Joris, you're right. You can use the method fetch() to send the form's html to the user's mailbox:

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,
  });
...

这篇关于如何访问或调用“将此表格发送给他人"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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