Sending Email

The sendEmail() function is the main and only runner function for this script. To have this function respond to new form responses, please add sendMail() as an installable trigger in your project. Please see the installable triggers documentation for more information.

Your project information must be added to this config object before the sendEmail() function will work correctly. Please see the documentation for config for a description of required parameters.

For debugging this script, please see the sendMail function below or the debug.js file for more information.

Author
  • unforswearing

Members

(inner, constant) activeSpreadsheet :Object

Get the spreadsheet object for the active spreadsheet. Uses the Google Apps Script SpreadsheetApp class.

Type:
  • Object

(inner) procParams

procParams is created using values from the config object. The parameters in this procParams object will default to the imported config object. New information will be calculated from the active sheet where necessary. Do not modify the procParams object directly!

(inner, constant) sheetName :string

Use the activeSpreadsheet object to retrieve the name of the current sheet via the getName method.

Type:
  • string

Methods

(inner) getLastColumnLetter() → {string}

A method to retrieve the letter of the last used column in the spreadsheet. Use getLastColumnLetter as the value for the the config object parameter data.sheetInfo.lastColumnLetter. This is set by default in the sendMail function.

Returns:

The last column letter as a string.

Type: 
string
Example
// Example: modify the script to retrieve an arbitrary range
// from your Google Spreadsheet
const getLastRange = () => {
  let lastCol = getLastColumnLetter()
  return activeSpreadsheet.getRange(`A30:${lastCol}30`)
}

(inner) sendMail(debug) → {void}

'sendMail()` is the main runner function. Be sure to add this functiom as an installable trigger in your project. See the installable triggers documentation for more information.

Debugging

sendEmail(true) to send all notifications to 'admin' for testing. The debugRunner function is equivalent to running sendMail(true) - all actions between debugRunner and sendMail(true) are equivalent. Both functions will send all runtime notifications to the email address listed in procParams.data.admin instead of the recipient listed in procParams.data.recipient. This is most useful for testing.

Parameters:
NameTypeDescription
debugboolean

specify whether the script should send errors to admin

Returns:
Type: 
void