How to run a Google Apps Script on a hidden sheet

wjwelch1

I have a sheet that is hidden that determines who will be emailed. The script that I have now will not run without having the sheet opened. Is it possible to run that GAS without having to unhide the hidden sheet?

function sendEmails() {
   var sheet = SpreadsheetApp.getActiveSheet();

   var range = sheet.getRange(1,3);   
   var email = range.getValues();     
   var emailAddress = email[0][0];    

   var range = sheet.getRange(2,3);   // Fetch the range of cells E1:E1
   var CC = range.getValues();        
   var ccEmail = CC[0][0];            

   var range = sheet.getRange(3,3);   // Fetch the range of cells E2:E2
   var subject = range.getValues();   // Fetch value for subject line from above range
   var EmailSubject = subject[0][0];  

   var range = sheet.getRange(5,4);   
   var message = range.getValues();     
   var messageBody = message[0][0];    


   MailApp.sendEmail({  to: emailAddress,   cc: ccEmail , subject: EmailSubject, body: messageBody, });


    }
ScampMichael

getSheetByName(name)

var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Expenses");

https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#getSheetByName(String)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get information on hidden rows from Google Sheet API without Google Apps Script

How to Preserve Sheet Formats and Translate? ( Google Apps Script, google sheet )

How to print the data of an array into a Google sheet with Google Apps Script

How to add the onOpen trigger to a Google Sheet with Google Apps Script?

Google Apps Script - How to send HTML email from Sheet?

How to extract the pubhtml ID in google sheet using Apps Script?

Google Apps Script how to export specific sheet as csv format

How to embbed a Charts.Chart to Google Sheet (Script Apps)

How to get specific sheet by id in Google Apps script?

Apps Script (Google Sheet) - How to customize the fotmat in a concatened string?

Google Apps Script: Google Sheet Grouping

Google sheet: Run script with similar sheet name

How to request or get the permission of google spread sheet access in the apps script of other sheet?

Apps Script "setFormulas" in Google Sheet: how to set the correct row in reference to other sheet?

google apps script sheet Calculation control

Apps Script - Export JSON properly into Google Sheet

google apps script - batch setValues() on Sheet

get last update of google sheet in apps script

Indent pretty JSON in Google Sheet Apps Script

Running apps script in Google Sheet app

Google Apps Script print sheet with margins

Google sheet + Apps script: faster then for loop

Adjusting JS code to Apps Script in Google sheet

Google apps script - automatically filter the active sheet

Copy sheet to another spreadsheet [Google Apps Script]

Google Apps Script - setvalues not working on sheet

Max size Google sheet, with apps script

Google Apps Script Sheet extract numbers as string

Run Google Apps Script in Android