- emailConfig
-
config.js
contains the configuration for thesendMail
function. Theconfig
object must be completed for thesendMail
function to work correctly. This object is passed to [the sendEmail function](#module_sendEmail..sendMail) with values from the current sheet environment via [the procParams object](#module_sendEmail..procParams).
Please see the documentation for the parameters inconst config
below. All parameter values areundefined
by default. - sendEmail
-
The
sendEmail()
function is the main and only runner function for this script. To have this function respond to new form responses, please addsendMail()
as an installable trigger in your project. Please see [the installable triggers documentation](https://developers.google.com/apps-script/guides/triggers/installable#google_apps_triggers) for more information.
Your project information must be added to this config object before thesendEmail()
function will work correctly. Please see the documentation for [config](#module_emailConfig..config) for a description of required parameters.
For debugging this script, please see [the sendMail function](#module_sendEmail..sendMail) below or the [debug.js file](#module_debug) for more information. - debug
-
The
debugRunner
function is equivalent to runningsendMail(true)
- all actions between debugRunner and sendMail(true) are equivalent. Both functions will send all runtime notifications to the email address listed inprocParams.data.admin
instead of the recipient listed inprocParams.data.recipient
. This is most useful for testing.
config.js
contains the configuration for the sendMail
function.
The config
object must be completed for the sendMail
function
to work correctly. This object is passed to [the sendEmail function](#module_sendEmail..sendMail) with values from the current sheet environment via
[the procParams object](#module_sendEmail..procParams).
Please see the documentation for the parameters in const config
below.
All parameter values are undefined
by default.
Update const
with values specific to your project.
Kind: inner constant of emailConfig
Properties
Name | Type | Description |
---|---|---|
admin | string |
Admin will receive error notifications |
formName | string |
The name of the form used to add responses to your spreadsheet |
recipient | string |
Add email addresses here. All form responses will be sent to any address added. Addresses may be for one individual or an array of addresses for multiple recipients. |
emailFooter | string |
|
sheetId | string |
Property |
sheetNameFilter | string |
|
subjectFilter | string |
|
sheetInfo | Object |
The first column is set to 'A' by default. To use a different first column modify the |
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](https://developers.google.com/apps-script/guides/triggers/installable#google_apps_triggers) 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](#module_emailConfig..config) for a description of
required parameters.
For debugging this script, please see [the sendMail function](#module_sendEmail..sendMail) below or the [debug.js file](#module_debug) for more information.
See: config
Author: unforswearing
procParams
is created using values from [the config object](#module_emailConfig..config).
Do not modify the procParams
object directly! The parameters
in this procParams
object will default to the imported config file,
calculating information from the active sheet only where necessary.
Kind: inner property of sendEmail
Get the spreadsheet object for the active spreadsheet. Uses the Google Apps Script [SpreadsheetApp class](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app).
Kind: inner constant of sendEmail
Use the activeSpreadsheet
object to retrieve the name
of the current sheet via the [getName)](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#getName()) method.
Kind: inner constant of sendEmail
A method to retrieve the letter of the last used column
in the spreadsheet. Use getLastColumnLetter as the value for
the [the config object](emailConfig~config) parameter
data.sheetInfo.lastColumnLetter
. This is set by default in
the sendMail
function.
Kind: inner method of sendEmail
Returns: string
-
The last column letter as a 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`)
}
'sendMail()` is the main runner function. Be sure to add this functiom as an installable trigger in your project. See [the installable triggers documentation](https://developers.google.com/apps-script/guides/triggers/installable#google_apps_triggers) for more information.
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.
Kind: inner method of sendEmail
Param | Type | Description |
---|---|---|
debug | boolean |
specify whether the script should send errors to |
- ~sendMail(debug) ⇒
void
extract helper code and info from procParams (var parameters) assumption: parameters.helper contains an object of helper vars / funcs var helper = parameters.helper;
Kind: inner property of sendMail
open the sheet for parsing
Kind: inner property of sendMail
sheetInfo = { firstCol, lastCol }
Kind: inner property of sendMail
####### sheetInfo.rangeString
Get the latest response range as text eg. "A10:G10"
Kind: static property of sheetInfo
####### sheetInfo.questions
get the values for question and latest response ranges
Kind: static property of sheetInfo
####### sheetInfo.submissionData[undefined]
change the date formatting if needed
Kind: static property of sheetInfo
tsi === time stamp index
Kind: inner property of sendMail
create the submission info table and styles for html emails table rows will be pushed to the dataTable column in the loop below
Kind: inner property of sendMail
add styles for full table and nest the dataTable rows in table tags
Kind: inner property of sendMail
Use admin email address if debug is true, otherwise use the script default
Kind: inner property of sendMail
create email subject
Kind: inner property of sendMail
add a company logo if desired. otherwise, comment out the two lines below
Kind: inner property of sendMail
create the email body
Kind: inner property of sendMail
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.
This function is added as a convenience for testing the script againt the latest form response. To automate this process you may add this function as an installable trigger in your project. See [the installable triggers documentation](https://developers.google.com/apps-script/guides/triggers/installable#google_apps_triggers) for more information.
Kind: inner method of debug
Param | Type | Description |
---|---|---|
admin | string |
The email address to send errors |