title: Extending a Google Sheets script
body: <p>I have my first Google script (below) that checks one cell A8 (DaysToMOT) to see whether a vehicle is less than 16 days to require an MOT, and if so, it sends an email to alert.</p>
  <p>Everything works great but it only selects one cell, and so the email it sends out doesn't have the vehicle details (ie: D8 (make), E8 (model), F8(colour), and G8 (VRN).</p>
  <p>A Blue Renault Clio car (SHX 6449) will come due for MOT in 15 days - instead of simply - A courtesy car will come due for MOT</p>
  <p>I then also need to extend this script so that it goes on to check Row 9, 10, 11, 12 etc etc and perform the same check but only send one email which should include:</p>
  <p>A Blue Renault Clio car (SHX 6449) will come due for MOT in 15 days. A Red Kia Sportage car (RHZ 4461) will come due for MOT in 15 days. etc</p>
  <pre><code>    function CheckMOT() {
  // Fetch the No of Days to MOT
    var DaysToMOTRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&quot;Courtesy car MOT Tracker&quot;).getRange(&quot;A8&quot;); 
    var DaysToMOT = DaysToMOTRange.getValue();
    // Check totals sales
    if (DaysToMOT &lt; 16){
  
  
    // Fetch the email address
  var emailRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&quot;Courtesy car MOT Tracker&quot;).getRange(&quot;B1&quot;);
  var emailAddress = emailRange.getValue();
  // Send Alert Email.
  var message = 'Hello!\n\nThis is an automated email alert triggered and sent from the Courtesy Tracker Google sheet. \n \nA courtesy car will come due for MOT in '+ DaysToMOT +' days. \n\nPlease book this vehicle in ASAP and update the sheet accordingly. \n\nThanks in advance\n\nBye!' // Second column
  var subject = 'URGENT MOT Booking required for Courtesy Car';
  MailApp.sendEmail(emailAddress, subject, message);
                       }
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/oLcVM.png" rel="nofollow noreferrer">spreadsheet example</a></p>