Google Apps脚本:如何访问或致电“将此表单发送给其他人”? [英] Google Apps Script: how to access or call "Send this form to others"?

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

问题描述

我附有Google Apps电子表格的表单。这是一种让我的同事将议程项目提交给我们每周审核会议的形式。我正在编写一个脚本来自动发送提醒给相关人员。

为了减少烦人和对他们来说很乏味,我想实际上将这个表格嵌入到电子邮件中。 Google文档提供了手动发送表单的方式:电子表格>表单>发送表单。但是,我无法在Google Apps脚本文档中找到任何可让我触发此功能的方法,例如


  • 像sendFormInEmail

  • 访问电子邮件友好型表单HTML,我可以将其分配给 sendEmail方法
  • 在Google Apps中触发任意菜单项

  • 其他内容
  • li>


我可以通过从电子邮件中提取生成的HTML并将其指定为htmlBody参数来做一个解决方法,但是我必须手动每次我们要更改表格时更新html - 不是我想要发生的事情。



有什么建议吗?

解决方案

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

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


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.

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.

  • A method like sendFormInEmail
  • Access to the email-friendly form HTML, which I could assign to the htmlBody argument of the sendEmail method.
  • Trigger an arbitrary menu item in Google Apps
  • Something else?

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.

Any suggestions?

解决方案

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

这篇关于Google Apps脚本:如何访问或致电“将此表单发送给其他人”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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