Google Calendar AutomationDifficulty: Beginner⚡ Time-driven (Daily 6-7 AM)

Automated Daily Morning Agenda Email Briefing

Runs every morning at 7:00 AM, compiles all calendar appointments scheduled for the day, and sends a clean briefing email to your inbox.

Required OAuth Scopes: https://www.googleapis.com/auth/calendar.readonly • https://www.googleapis.com/auth/gmail.send
Code.gs (Apps Script V8 Runtime)
function sendDailyAgendaEmail() {
  const today = new Date();
  const calendar = CalendarApp.getDefaultCalendar();
  const events = calendar.getEventsForDay(today);
  
  let body = '<h3>Good Morning! Here is your schedule for today:</h3><ul>';
  
  if (events.length === 0) {
    body += '<li>No scheduled calendar events today. Deep work day!</li>';
  } else {
    events.forEach(evt => {
      const time = Utilities.formatDate(evt.getStartTime(), 'GMT+05:30', 'hh:mm a');
      body += '<li><strong>' + time + ':</strong> ' + evt.getTitle() + '</li>';
    });
  }
  
  body += '</ul><p>Sent automatically via Google Apps Script.</p>';
  
  GmailApp.sendEmail(Session.getActiveUser().getEmail(), 'Your Daily Schedule for ' + today.toDateString(), '', {
    htmlBody: body
  });
}

Line-by-Line Code Explanation

Line 3-4: Fetches calendar appointments for the current date.
Line 6-17: Loops through meetings formatting start times and titles into an HTML list.
Line 19-21: Emails the digest directly to the authenticated user.

Step-by-Step Setup & Deployment

  1. Paste into Apps Script and adjust time zone string if needed.
  2. Add a daily time-driven trigger between 6 AM and 7 AM.

Best Practices for Quota & Rate Limit Management

When deploying this automation in Google Workspace, adhere to these operational principles:

  • Batch Reads & Writes: Never execute getValue() or setValue() inside loops. Read ranges into memory in 1 call, process arrays in V8 memory, and commit changes with a single setValues() call.
  • Execution Timeouts: Apps Script terminates scripts exceeding 6 minutes. For multi-thousand row datasets, implement batch pagination with resume timestamps stored in PropertiesService.
  • OAuth Permissions: Scope your manifest (appsscript.json) narrowly to prevent security prompts from alarming external team members.

Frequently Asked Questions

Is Google Apps Script completely free to use?

Yes. Google Apps Script is built into all free Google accounts and Google Workspace editions. There are no server fees or subscription costs for running scripts within daily quotas.

Can I run this script on an automated schedule without keeping my computer on?

Yes. Time-driven triggers execute on Google's cloud infrastructure. Your script will run reliably even when your computer is closed or offline.

More Google Calendar Automation Snippets