スプレッドシートで選択した人にリクエストを含むメールを送信するための Google Apps Script があります。
function sendRequestEmail() {
var data = SpreadsheetApp.openById(SPREADSHEET);
if(!employee_ID) {
employee_ID = getCurrentRow();
if (employee_ID == 1) {
var employee_ID = Browser.inputBox("Você precisa selecionar um assistido?", "Choose a row or type its number here:", Browser.Buttons.OK_CANCEL);
}
}
// Fetch variable names
// they are column names in the spreadsheet
var sheet = data.getSheets()[0];
var columns = getRowAsArray(sheet, 1);
Logger.log("Processing columns =" + columns);
var employeeData = getRowAsArray(sheet, employee_ID);
Logger.log("Processing employeeData = " + employeeData);
// Assume first column holds the name of the person
var email2Send = "pythonist@example.com";
var title = "Request by email";
var name = employeeData[0];
var mother_name = employeeData[1];
var message = "Hi, I have a request for you, " + name + ", this is... example";
// HERE THE
// CONFIRMATION BUTTON!!!
MailApp.sendEmail(email2Send, title, message);
}
そして、メールを送信する前に、次のような確認ボタンが必要です。
function showConfirmation(name, email2Send) {
var app = UiApp.createApplication().setHeight(150).setWidth(250);
var msg = "Do you confirm the request to " + email2Send + " about " + name + "?";
app.setTitle("Confirmation of request");
app.add(app.createVerticalPanel().add(app.createLabel(msg)));
var doc = SpreadsheetApp.getActive();
doc.show(app);
}
したがって、ユーザーが [OK] を押すと、アプリは行を実行しMailApp.sendEmail(email2Send, title, message);
、電子メールを送信します。
私は自分の無知を認めなければなりません。ハンドラーに関する本「Google Apps Script」(Oreilly、James Ferreira 著) の第 4 章を読んでいます。Google のドキュメントで提供されている例を使用してみました (コードは既に削除されています!)。しかし、理解できないエラーに遭遇しました。
使用したコードは次のサンプルです。
var ui = DocumentApp.getUi();
var response = ui.prompt('Getting to know you', 'May I know your name?', ui.ButtonSet.YES_NO);
// Process the user's response.
if (response.getSelectedButton() == ui.Button.YES) ... DO THIS
この単純なプロジェクトには緊急性があるため、回答をさらに調査する前にこの質問をすることを許してください(回答を待ちながら検索しています)。では、このコードで確認/キャンセル ボタンを使用するにはどうすればよいでしょうか。