title: Workflow using Google Apps Script - I need to email the user in my first step
body: <p>I'm creating a workflow process that will email a body of a form to users in that workflow. I can iterate through the users and send an email but I do not now how to pass the "e" parameters for the body of the email. I actually already have a function that will send the body , but I need to include this in my step process (I think). </p>
  
  <p>Hear is my code that will send email</p>
  
  <pre><code>function sendEmail_(e) {
  
  
    var sheet = SpreadsheetApp.openById("0AuCblud0Ss7sdfA1bXZjYXA0Y0IhthkhUQm5vWG02MVE").getActiveSheet();
  
  
   var row = sheet.getLastRow()+1;
  
   sheet.getRange(row,3).setValue(row);
  
      var range = sheet.getRange(sheet.getLastRow(),1,1,23);
   range.setValues([[e.parameter.LastName,e.parameter.FirstName,row /*e.parameter.DivisionName*/,e.parameter.EffectiveDate,e.parameter.Status, 
  
            e.parameter.Network,e.parameter.EmployeeNewPosition,e.parameter.DivisionFolder,e.parameter.SpecificIndividual,
                      e.parameter.Email,e.parameter.username,e.parameter.who,e.parameter.Banner,e.parameter.RMS ,e.parameter.HAPPY,e.parameter.Sweeps,
                     e.parameter.Comcate,e.parameter.Netviewer,e.parameter.NetDispatcher,e.parameter.IMARS,"pending", e.parameter.DivHeadEmail,  e.parameter.Director]]);
  
  
     var body = '&lt;form action= &lt;form action = " https://sites.google.com/a/macros/wichitafallstx.gov/s/AKfycbxAOGO6q9ofauf34xlDA9sLG8sUXeZsuvQkDKATOQ/exec" method ="post"&gt;' +
  
        "&lt;b&gt;Last Name:&lt;/b&gt;" + e.parameter.LastName +  '&lt;br&gt;&lt;br&gt;' + 
   "&lt;b&gt;First Name:&lt;/b&gt;" +  e.parameter.FirstName +  '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Division Name:&lt;/b&gt;" + e.parameter.DivisionName +  '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Effective Date:&lt;/b&gt;" + e.parameter.EffectiveDate +  '&lt;br&gt;&lt;br&gt;' + 
    "&lt;b&gt;Employee Status:&lt;/b&gt;" + e.parameter.Status +  '&lt;br&gt;&lt;br&gt;' + 
      "&lt;b&gt;Network:&lt;/b&gt;" + e.parameter.Network +  '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Employee New Position:&lt;/b&gt;" + e.parameter.EmployeeNewPosition +  '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Division Folder:&lt;/b&gt;" + e.parameter.DivisionFolder +  '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Specific Individual:&lt;/b&gt;" + e.parameter.SpecificIndividual +   '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Email:&lt;/b&gt;" + e.parameter.Email +  '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Username:&lt;/b&gt;" + e.parameter.username +  '&lt;br&gt;&lt;br&gt;' +  
  "&lt;b&gt;who:&lt;/b&gt;" + e.parameter.who +  '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;Banner:&lt;/b&gt;" + e.parameter.Banner + '&lt;br&gt;&lt;br&gt;' + 
  "&lt;b&gt;RMS:&lt;/b&gt;" + e.parameter.RMS + '&lt;br&gt;&lt;br&gt;' + 
    "&lt;b&gt;HAPPY:&lt;/b&gt;" + e.parameter.HAPPY + '&lt;br&gt;&lt;br&gt;' + 
      "&lt;b&gt;Sweeps:&lt;/b&gt;" + e.parameter.Sweeps + '&lt;br&gt;&lt;br&gt;' + 
        "&lt;b&gt;Comcate:&lt;/b&gt;" + e.parameter.Comcate + '&lt;br&gt;&lt;br&gt;' + 
          "&lt;b&gt;Netviewer:&lt;/b&gt;" + e.parameter.Netviewer + '&lt;br&gt;&lt;br&gt;' + 
            "&lt;b&gt;NetDispatcher:&lt;/b&gt;" + e.parameter.NetDispatcher + '&lt;br&gt;&lt;br&gt;' + 
              "&lt;b&gt;IMARS:&lt;/b&gt;" + e.parameter.IMARS + 
        '&lt;br /&gt;' + 
         '&lt;br /&gt;' +    
  
           '&lt;input type="hidden" name="row" value=" ' + row +' "/&gt;' +
         '&lt;input type="submit" value="Approve" onclick="approve()" /&gt;' +
           '&lt;/form&gt;' 
              ; 
  
  
  
    //  var owners = e.parameter.DivHeadEmail;
  //  var mail = MailApp.sendEmail(owners, "test",'' , {htmlBody:body});
  
  
  }
  </code></pre>
  
  <p>I need to email the html body from the code above with the step in the work flow in this "createStep" function. I dont know how to reference the variable "body" from the code above to this function or even if I could include the html body in this function. How would I do this?</p>
  
  <pre><code>function createStep(approvers) {
  
  
  
  
  
   var step = new Object();//javascript object
  
    step['numberOfApprovers'] = approvers.length; //set number of approvers passed in array
   step['approvers'] = approvers.slice(0); //slice copies array 
    step['status'] = 'pending'; //set statust to pedning
  
    for (var i in approvers)
      step[approvers[i]] = 'pending'; //iterate field that indicates specific status
  
  for (var m in approvers)
      step[approvers[m]] = MailApp.sendEmail(approvers, "test", "test",{htmlBody:body});
  
    return step
  
  
  
  }
  </code></pre>