I have a Gmail account that it is only monitored Monday through Thursday. I would like to set something up to automatically send a canned reply for emails received between Thursday afternoon and Monday morning informing the sender that the email will not be seen until Monday morning, and giving emergency contact information.
I don't think this can be done directly in Gmail right now. (Vacation replies need to be manually turned on and off, and filters for canned email do not include any date/time options.) Can I set Gmail "out of office" replies for every week recurring? also suggests that this is was possible in Gmail, at least at the time of that question.
Is there any work-around or way to do some simple coding to accomplish this? I have a software development background, but I'm not aware of what (if any) options are available to the general public to extend Gmail.
Best Answer
Here is an Apps Script that does this. You can click this start scripting link to open script editor in Google Drive. Then:
The logic of the script is explained below.
The script only does something if the current local day/time is
[5,6,0].indexOf(day)
), orWhat it does is check all messages received in the last 5 minutes (
interval
in the script) and replies to each with a canned text.It is important that the two time intervals match: the interval at which the trigger is set, and the one set in the script. Otherwise the script will either fail to reply to some messages, or will reply several times.
Remarks
You can try to run this every minute instead of every 5 minutes; but I wasn't sure if this would exceed the maximal running time allowed to scripts for a day (1 hour total running time).
I considered more sophisticated forms of this: with adding a label "auto-reply", or with storing the time of last run in ScriptProperties. But the above gets the job done, and wins in simplicity.