Odd scheduling for automatic emails

19 views
Skip to first unread message

Clément Milewski

unread,
Jan 18, 2021, 10:32:33 AM1/18/21
to Google Apps Script Community
Greetings,
I recently discovered the world of Google Spreadsheet's Script Editor tool to send automatic emails. 
I saw however, that despite the copious amount of possibilities this tool offered, it did not have the required options I was looking for regarding scheduling. I would like to send automatic emails every 19 days, which is an odd pattern, and I didn't find any documentation for this. Annual events I would like to schedule can also be different every year (they are based on the sun's equinox, which can differ every year from march 20th to march 22nd, moving everything).
I would not mind filing every date in the spreadsheet and have the code execute when needed, if such a solution is possible, or maybe none of it is.
Any insights ?

Cheers,

Alan Wells

unread,
Jan 18, 2021, 10:50:01 AM1/18/21
to Google Apps Script Community
A time based trigger does have an

everyDays(integer)

method.
You probably need to run the code to create the trigger on a day that is 19 in front of the target date.
So, if the target date was 5 days away from today, then you'd want to create a trigger for 5 days away,
and then create the next one for 19 days away.

See documentation at:

Clément Milewski

unread,
Jan 18, 2021, 11:26:39 AM1/18/21
to Google Apps Script Community
Wow, thanks a lot for the prompt and useful reply ! Seems it just shows how much of a beginner I am on the subject.

Cheers, 

Laurie Nason

unread,
Jan 19, 2021, 1:00:48 AM1/19/21
to google-apps-sc...@googlegroups.com
Further to Alan's answer, you could have a sheet with the dates you want to run a script for - and because you want to run different scripts on different days, I think you might want a column of checkboxes denoting which event script you want to run (you may want to run multiple scripts on the same day) 
You then have a time based trigger that runs at 1am every day (or whenever you want it to run) and checks to see if today's date matches anything in your list of dates - if it does, you can then see which scripts you need to run in the other columns by checkbox value and run them or not.
If the day's date doesn't exist in your list of dates, do nothing until  the following morning.
You can easily generate a list of 19 day dates in a sheet by entering your start date in box A1 then in the cell below use A1+19 and copy it down as many rows as you need. 
Hopefully that will get you going.
Laurie

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/ce4c5168-5ad5-47e1-8b35-24e0a4d2c98cn%40googlegroups.com.


--

Laurie Nason 

The KAUST School – Operational Analyst

Information Technology Support
Deep in the Bowels of the School
Landline: +966-12-808-6853

Adam Morris

unread,
Jan 19, 2021, 1:14:34 AM1/19/21
to google-apps-sc...@googlegroups.com
Schedule a daily schedule that checks the date and proceeds if it’s the 19th
Otherwise, just end silently

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
--
Reply all
Reply to author
Forward
0 new messages