2014-12-19 4 views

답변

1

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 protected]"; 

//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); 

} 

}.

doc.addViewer(emailAddress); 

희망 하시겠습니까?