So I have a Google Form that feeds a Google Docs Spreadsheet. This form is for new people to our town to signup for our newcomers group.
I want to write a Google Apps script that will programmatically send a reminder e-mail to users who have not paid their dues 10 days after they submitted the form.
Should be easy, right?
Here's a link to a copy of the Spreadsheet with personal data redacted out:
https://docs.google.com/spreadsheet/ccc?key=0AjsoIob8dJfodG9WN0ZmWUE1ek9rc3JrVFpDQ0J0OGc
Seems as if I should be able use Column A ("Timestamp") with some sort of a comparison to now() to determine the 10 day part. And to get the have not paid their dues just has to be Column D does not equal Yes. The recipient's e-mail address is, obviously, in Column X.
I've already written a script to send a confirmation e-mail to the recipient "On Form Submit." So I'm comfortable with the MailApp.sendEmail class.
And if you notice the "Updaid" tab, you'll see that I've tackled using a query to pull out people who haven't paid.
But I'm not sure how to get the MailApp.sendEmail class to operate on data that's already IN a sheet. That is not triggering automatically when the form is submitted.
And I don't know how to adapt my query to account for the 10 days ago bit.
And I'm not even sure I should be USING a query for this application.
Can anybody right my path?
Thanks.
It should be pretty easy to write the compare function, you then would just need to add your own daily trigger.
Look to the Resources-> Triggers in the script editor.
Here is the link to the Triggers tutorial from Google.
The easiest way to know if a date is 10 days later is probably to count the milliseconds !
I know it sounds like a joke but it isn't ;-)
Example :
The method getTime() returns the number of milliseconds from the reference date, it will work till 2070 so I guess it is safe to use for now ;-)
The trigger issue is already solved in Cornelius's answer, thx
EDIT : here is a possible code to do what you want : (tested on your sheet)
note that I splitted the code in 2 functions for clarity but when it will run as a trigger you should combine both functions in one to get an automatic checking...