谷歌Apps脚本 - 自动通过电子邮件和共享
问题描述:
我试图写一个小谷歌企业应用套件脚本,将发送一封确认邮件,并自动共享的文件夹与登录的用户,他们填写一份表格后。下面是该脚本:谷歌Apps脚本 - 自动通过电子邮件和共享
function formSubmitReply(e) {
MailApp.sendEmail({
to: Session.getActiveUser().getEmail(),
subject: "Keuka College Brand Download Center",
htmlBody:
"<p>Thank you for requesting access to the Keuka College Brand Download Center. Your access has been approved.</p>" +
"<p>You may access the download center by <a href='https://drive.google.com/a/keuka.edu/folderview?id=0B856ZeGoaGT_MG5BMEtEVGwzYkk&usp=sharing'>using this link,</a> " +
"visiting <a href='http://brand.keuka.edu'>Keuka College Brand Central,</a> or through your Google Drive.</p><p>Please contact the Office of Marketing and Communications " +
"with any questions you may have.</p>",
name: "Keuka College",
replyTo: "[email protected]"
});
var folder = DocsList.getFolder('Brand Download Center');
folder.addViewer(Session.getActiveUser());
}
这似乎是工作,但它保持它通过电子邮件发送给我 - 不是谁填写该表格的用户。我不确定它是否正确共享。
有人可以提供一些见解吗?这是我第一次使用Google Apps脚本。
答
Session.getActiveUser()
是使用表格编辑器,并创建调用此函数触发用户的用户。
你要我们怎么办那漫天的形式向用户。
查看文档here看你如何检索该值。请注意,它将为only be available if you are in a domain。
编辑(抱歉耽搁)
这里是一个示例代码来说明如何获得formApp形式受访者(仅适用于GAFE或GA业务)
它将向您发送一封邮件,其中包含最后一个表单提交者的姓名(不要忘记创建一个可安装的onEdit触发器来测试此信息)。
function onSubmit(){
var form = FormApp.getActiveForm();
var formResponses = form.getResponses();
var lastResponse = formResponses[formResponses.length-1];
var user = lastResponse.getRespondentEmail()
var userString = 'user = '+user;
MailApp.sendEmail(Session.getActiveUser().getEmail(),'form submission report',userString);
}
谢谢。我改变了它如下,但它似乎仍然没有工作。有什么建议么? (Partial Code):function formSubmitReply(e){ var email = e.getRespondentEmail(); MailApp.sendEmail({ 到:电子邮件, – Pete 2014-10-10 17:43:02
而且您使用的企业或EDU帐户 – 2014-10-10 17:44:40
EDU,我相信 – Pete 2014-10-10 17:47:02