Task guide
Run an Apps Script function every day
Run the setup function once, then Apps Script calls the reminder function each day around your chosen hour.
1 · Prepare
Put these pieces in place
- Use an account that can send email through Gmail.
- Decide whether a daily reminder email is useful before installing the trigger.
- Keep both functions in the same Apps Script project.
Change these values
- Run hour
9The trigger runs around this hour in the script project time zone.
- Email subject
Daily script reminderThis is the subject delivered to the script owner.
- Handler name
sendDailyReminderThe setup function checks this name before making another trigger.
2 · Review before running
What the script can access and change
Permissions you approve
- Create and view triggers in this Apps Script project.
- Send a daily email from your Google account.
Effects of one run
- Creates one daily time trigger when one is not already installed.
- Sends the script owner one reminder email each day around 9 AM in the project time zone.
3 · Copy
Paste this into the Apps Script editor
Create or open a script file, replace the example values marked above, then save the project.
const RUN_HOUR = 9; // The trigger runs around this hour in the script project time zone.
const EMAIL_SUBJECT = 'Daily script reminder'; // This is the subject delivered to the script owner.
const HANDLER_NAME = 'sendDailyReminder'; // The setup function checks this name before making another trigger.
function createDailyReminder() {
const alreadyInstalled = ScriptApp.getProjectTriggers().some((trigger) => {
return trigger.getHandlerFunction() === HANDLER_NAME;
});
if (alreadyInstalled) return;
ScriptApp.newTrigger(HANDLER_NAME)
.timeBased()
.everyDays(1)
.atHour(RUN_HOUR)
.create();
}
function sendDailyReminder() {
const recipient = Session.getEffectiveUser().getEmail();
GmailApp.sendEmail(recipient, EMAIL_SUBJECT, 'Your daily Apps Script reminder ran successfully.');
} 4 · Run safely
Follow these steps in order
Paste both functions
The first function installs the schedule. The second function is the work that runs each day.
Run the setup function once
Choose createDailyReminder and run it. Approve the requested access when Google asks.
Check the trigger list
In Apps Script, open Triggers from the left sidebar to see the daily schedule.
5 · Confirm
How to tell it worked
The trigger list shows sendDailyReminder as a daily trigger, and the script owner receives the reminder after it runs.
If the result is different
Troubleshooting
- The setup function seems to do nothing.
- It intentionally stops when a trigger for sendDailyReminder already exists. Check the Triggers list instead of running it repeatedly.
- The email arrives at an unexpected time.
- Check the Apps Script project time zone, then change RUN_HOUR to the hour you want and reinstall the trigger.
Technical details
Names used in this script
Open these details when you want to adapt the example or look up an exact service or method name.
Show Apps Script symbols and service pages
Apps Script symbols
Keep going
Related tasks, basics, and apps
- Task guide Respond to a Google Form submission
Add a small response function, then install a form-submit trigger so each new answer produces a private email summary.
- Task guide Save labeled Gmail attachments to Drive
Choose the email threads yourself by adding a Gmail label, then copy their attachments into an existing Drive folder.
- Object reference Trigger
A ScriptApp.Trigger is one installed schedule or event rule owned by the current user in this project. Use ScriptApp.getProjectTriggers() to inspect its handler function or delete it with ScriptApp.deleteTrigger().
- Object reference Trigger builder
ScriptApp.newTrigger(functionName) returns a TriggerBuilder that configures a timeBased(), forSpreadsheet(), or forForm() trigger before create() saves it.
- Basics Run your first Apps Script function
Open Extensions > Apps Script from a Google Sheet or Doc to reach the code editor. Replace the starter function myFunction() { }, save with Ctrl+S, press Run, and read what Logger.log printed.
- Basics Apps Script permissions and authorization
Before a script can read your sheet or send your mail, you give it permission to access a list of OAuth scopes. This page walks through each authorization screen, explains @OnlyCurrentDoc, and shows how to revoke access.
- Basics Google Apps Script triggers explained
A Google Apps Script trigger runs a function when an event happens, without pressing Run. Simple triggers like onEdit and onOpen need no setup, while installable triggers run on a schedule or form submit using the OAuth scopes approved by their owner.
- Google app Triggers
A trigger is a saved schedule or event rule in ScriptApp that runs your function on time, on edit, or on form submit.
- Google app Gmail
GmailApp scripts can send messages, search threads, apply labels, and read attachments after you approve Gmail access for the project.