I am using Google Sheets for our company to track materials, inventory, and BOMs. I am using App Script to send an email with a PDF of the sheet once BOM inventory is completed. (This is my first time using App Script)
Here is my script:
function sendReport() {
var message = {
to: "
I am trying to have cell information entered in the places with "***" to reflect in the sent email. What code do I use for this? The rest of the script works great.
Answer
This gets your active sheet, then specifies Sheet1
by name. It proceeds to retrieve all data within the used range of Sheet1 and flattens it into a single list/array named dt. This means dt
now holds all the values from your sheet's filled cells in a simple ordered list:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Sheet1");
var dt = sh.getDataRange().getValues().flat();
Below is the full code:
function sendReport() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getSheetByName("Sheet1");
var dt = sh.getDataRange().getValues().flat();
var message = {
to: "