我有一个谷歌电子表格,其功能是通过电子邮件向网页发送网址。如何使用只读权限设置此网址?
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);
}
}