title: How to use a confirmation button in Google Apps Script spreadsheet embedded scripts?
body: <p>I have this Google Apps Script to send an email with a request to people I choose in a spreadsheet:</p>
  <pre><code>function sendRequestEmail() {
    var data = SpreadsheetApp.openById(SPREADSHEET);
    if(!employee_ID) {
      employee_ID = getCurrentRow();
      if (employee_ID == 1) {
        var employee_ID = Browser.inputBox(&quot;Você precisa selecionar um assistido?&quot;, &quot;Choose a row or type its number here:&quot;, 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(&quot;Processing columns =&quot; + columns);
    var employeeData = getRowAsArray(sheet, employee_ID); 
    Logger.log(&quot;Processing employeeData = &quot; + employeeData);
    // Assume first column holds the name of the person
    var email2Send = &quot;pythonist@example.com&quot;;
    var title = &quot;Request by email&quot;;
    var name = employeeData[0];  
    var mother_name = employeeData[1];
    var message = &quot;Hi, I have a request for you, &quot; + name + &quot;, this is... example&quot;;
    // HERE THE
    // CONFIRMATION BUTTON!!!                     
    MailApp.sendEmail(email2Send, title, message);
    }
  </code></pre>
  <p>And, before sending the email, I want a confirmation button, something like this:</p>
  <pre><code> function showConfirmation(name, email2Send) { 
    var app = UiApp.createApplication().setHeight(150).setWidth(250);
    var msg = &quot;Do you confirm the request to &quot; + email2Send + &quot; about &quot; + name + &quot;?&quot;;
    app.setTitle(&quot;Confirmation of request&quot;);      
    app.add(app.createVerticalPanel().add(app.createLabel(msg)));
    var doc = SpreadsheetApp.getActive();
    doc.show(app);
    }
  </code></pre>
  <p>So, if user press OK, the app will execute the line <code>MailApp.sendEmail(email2Send, title, message);</code> and send an e-mail.</p>
  <p>I have to admit my ignorance. I'm reading chapter 4 of the book &quot;Google Apps Script&quot; (Oreilly, by  James Ferreira) on handlers. I've tried using an example provided in the documentation from Google (already deleted the code!). But I came across an error that I could not understand.</p>
  <p>The code used were this sample:</p>
  <pre><code>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
  </code></pre>
  <p>I have some urgency in this simple project, so forgive-me for asking this question before research more for the answer (I'm searching for it while wating for the answer). So, how can I use a confirmation/cancellation button in this code?</p>