I'm Trying to send email using MailApp.sendEmail
in a Google Spreadsheet Script following this example: https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/ by @mhawksey
see: https://docs.google.com/spreadsheets/d/1mhY_hJMMPTmxq3TFAUHK0tKFhGYBpzus-dXE3U5TQdc/edit?usp=sharing
The Test web app for your latest code. function works. (email is sent)
But when I try to trigger the sendEmail()
via a POST
request it does not work.
I'm following the documentation: https://developers.google.com/apps-script/reference/mail/mail-app
And yet when I trigger the sendEmail()
function from my script, it does not send an email.
What am I doing wrong?
Looked at:
But I want to understand if I am doing something wrong...
Full Steps and code: https://github.com/nelsonic/web-form-to-google-sheet#12-google-apps-script
Thanks to @ZigMandel for pointing me the right direction ... here are the steps for anyone else facing this issue:
MailApp.sendEmail
MethodIn your Google Spreadsheet Script call:
MailApp.sendEmail("[email protected]", // to
"[email protected]", // from
"Your Subject Goes Here", // email subject
"What ever you want to say"); // email body
As per the docs: https://developers.google.com/apps-script/reference/mail/mail-app#sendemailto-replyto-subject-body
For this new functionality to work in your script you will need to "Save a New Version" and (Re-)Deploy your App! (simply clicking the "Save" is Not Enough!)
It's not immediately obvious but you have to click on "Manage Versions..." see: https://developers.google.com/apps-script/guide_versions
Then create your new version:
Select the latest project version to deploy:
Click "OK". No need to update the script url in your HTML form (it does not change - there are pros & cons to this...)
For the complete solution see: https://github.com/nelsonic/web-form-to-google-sheet