title: Google Apps Menu - Function with parameter
body: <p>Let's say I have this function:</p>
  
  <pre><code>function alertar(userEmail) {
     var doc = DocumentApp.getActiveDocument();
     // Get the URL of the document.
     var url = doc.getUrl();
     // Send yourself an email with a link to the document.
     var u = Session.getActiveUser();
  
     ui.alert('it worked');
     GmailApp.sendEmail(userEmail, "assunto", "hey, click here" +  url);
  
  }
  </code></pre>
  
  <p>And then I created menus as follows:</p>
  
  <pre><code> var editors = DocumentApp.getActiveDocument().getEditors();
   var m = ui.createMenu('uPaPoPe Actions');
   var subMenu = ui.createMenu('Escritores');
   for (var i=0;i&lt;editors.length;i++)
   {
     subMenu.addItem(editors[i].getEmail(), 'function()          {alertar("'+editors[i].getEmail()+'");}');  //line with problem
    }
  </code></pre>
  
  <p>How do I pass parameters to a function that requires them from a google apps script menu item? Doing any of the following constructions is not valid:</p>
  
  <pre><code>   subMenu.addItem(editors[i].getEmail(), 'function()          {alertar("'+editors[i].getEmail()+'");}');  
  
  
     subMenu.addItem(editors[i].getEmail(), 'alertar("'+editors[i].getEmail()+'");');  
  </code></pre>
  
  <p>This is allowed:</p>
  
  <pre><code>   subMenu.addItem(editors[i].getEmail(), 'alertar');  
  </code></pre>
  
  <p>But the latter does not allow me to pass the editor's email as parameter.</p>