Google表格网络应用以所有者身份运行脚本 [英] Google Sheets web app to run script as owner

查看:94
本文介绍了Google表格网络应用以所有者身份运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个简单的脚本,可以从电子表格发送电子邮件,我需要允许工作表的其他用户调用该脚本,但我希望该脚本以我(所有者)的身份运行,以便从我的帐户.我看过一些类似的问题和答案,但似乎没有任何效果.

Hi have a simple script that sends an email from a spreadsheet I need to allow the other users of the sheet to call the script but I want the script to be ran as me (the owner) so that the email is sent from my account. I've looked at some similar questions and answers but nothing seems to work.

我的工作表上有一个按钮,它使用以下代码调用doGet函数.

I've got a button on my sheet calling the doGet function with the following code.

function doGet(e){

  UrlFetchApp.fetch('https://script.google.com/a/----.org/macros/s/AKfycbxT------------------------------FK5GbrkI/exec').getResponseCode();

}

如果我从浏览器选项卡中转到URL,脚本运行正常,但单击电子表格上的按钮后无法正常工作

If I go to the URL from a browser tab script runs fine but I can't get it to work from clicking the button on my spreadsheet

推荐答案

您可以创建 standalone webapp来处理电子邮件.当用户调用脚本时,网络请求从电子表格的GAS绑定脚本发布到已发布的 webapp ,并且在webapp中,您可以通过自己的帐户发送电子邮件(即以我的身份执行该应用").您也可以传递参数,例如,电子邮件收件人和文本可以作为参数发送.这是一张清晰的图片:

You can create a standalone webapp to handle the emailing. When the user calls the script, a web request is issued from the GAS bound script of the spreadsheet to the published webapp, and in the webapp you can email from your own account (i.e., "Execute the app as: Me"). You can pass arguments as well, for example the email recipient and text could be sent as parameters. Here is a picture for clarity:

这篇关于Google表格网络应用以所有者身份运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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