【问题标题】:Google Apps Scripts - Send url with permissionsGoogle Apps 脚本 - 发送具有权限的 url
【发布时间】:2014-12-19 21:33:05
【问题描述】:

我有一个谷歌电子表格,它具有通过电子邮件向工作表发送网址的功能。如何设置此网址为只读权限?

function createAndSendDocument() {
// set active spreadsheet
var doc = SpreadsheetApp.getActiveSpreadsheet();

// Get the URL of the document.
var url = doc.getUrl();

// Get the email address of the active user - that's you.
var email = "email@gmail.com";

//add email
var ui = SpreadsheetApp.getUi();
var response = ui.prompt('Who do you want to send this to?', 'Type email below:', ui.ButtonSet.YES_NO);

// Get the name of the document to use as an email subject line.
var subject = doc.getName();
// Append a new string to the "url" variable to use as an email body.
var body = 'See the latest file: ' + url;

// Process the user's response.
if (response.getSelectedButton() == ui.Button.YES) {
email = email + ", " + response.getResponseText();
Logger.log('The user\'s name is %s.', response.getResponseText());
} else if (response.getSelectedButton() == ui.Button.NO) {
Logger.log('The user didn\'t want to provide a name.');

} else {
Logger.log('The user clicked the close button in the dialog\'s title bar.');
// Send yourself an email with a link to the document.
GmailApp.sendEmail(email, subject, body);

}

}

【问题讨论】:

    标签: google-apps-script google-sheets


    【解决方案1】:

    您可以检查此option 为该工作表添加查看器。

    doc.addViewer(emailAddress);
    

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多