I have a script set up to send out an email on receiving data from a form into a spreadsheet. However, the auto email generates from the spreadsheet, which takes a few seconds to update the fields - so if I use the onformsubmit trigger, the content of the auto email wrongly refers to the previous submission.

Is there a way to delay the auto email by a few seconds, giving the spreadsheet time to generate the right information before spitting out the email?

Any help appreciated!

Nick 

Here is the code so far:

```
    function EmailFormConfirmation() { 
      var ss = SpreadsheetApp.getActiveSpreadsheet(); 
      var sheet = ss.getSheetByName("Form responses");
      var email = sheet.getRange(2,9,1,1).getValue();  
      var message = "<HTML><BODY>"
         + "<P >Hi " 
         + sheet.getRange(4,9,1,1).getValue()
         + ","
         + "<P>You have received a new request, from <b>"
         + sheet.getRange(5,9,1,1).getValue()
         + "</b>.  "
         + sheet.getRange(8,9,1,1).getValue()
         + " asks:<i>"
         + "<br /><br />"
         + sheet.getRange(6,9,1,1).getValue()      
         + "</i><P>You can find your request on the log at number <b>"
         + sheet.getRange(10,9,1,1).getValue()
         + "</b>.  
         + "<br /><br />"
         + sheet.getRange(8,9,1,1).getValue()
         + "'s email address is:"
         + "<br /><br />"
         + sheet.getRange(9,9,1,1).getValue()   
         + "</HTML></BODY>";
        MailApp.sendEmail(email, "LMI Request", "", {htmlBody: message});   
    }

```