This Google Apps Script automatically extracts events from your school's emails and adds them to a shared Google Calendar, making it easier to keep track of important school dates and events.
- 🔍 Automatically searches for emails from your school's domain
- 📅 Extracts dates and times from email content
- 🗓️ Adds events to a shared Google Calendar
- 🏷️ Labels processed emails to avoid duplication
- ⏰ Can run daily or on-demand
- Go to Google Calendar
- Create a new calendar or use an existing one
- In calendar settings, find the Calendar ID
- It looks like:
something@group.calendar.google.com
- You'll need this ID for the script configuration
- It looks like:
- Go to Google Apps Script
- Create a new project
- Copy and paste the code from
school-calendar-script.js
into the editor - Modify the configuration variables at the top of the script:
const SEARCH_QUERY = "from:@yourschooldomain.org"; // Change to your school's email domain const TARGET_CALENDAR_ID = "your_calendar_id@group.calendar.google.com"; // Your calendar ID const DAYS_TO_LOOK_BACK = 7; // Adjust as needed const LABEL_NAME = "School-Processed"; // Label name for processed emails const SCHOOL_NAME_PREFIX = "School Event: "; // Customize the event prefix
- Save the project with a meaningful name (e.g., "School Calendar Integration")
-
Run the
testCalendarAccess
function first- Select it from the dropdown menu at the top of the editor
- Click the Run button (
▶️ ) - Grant the necessary permissions when prompted
- Check the execution logs to confirm success
- Verify a test event appears in your calendar
-
Run the main script manually
- Select the
processSchoolEmails
function from the dropdown menu - Click the Run button (
▶️ ) - Check the execution logs to see what happened
- Look for events in your calendar
- Select the
- Run the
setUpDailyTrigger
function once- This will configure the script to run daily at 6 AM
- You can modify the time in the script if needed
-
No events being added:
- Verify your school's email domain in the
SEARCH_QUERY
- Make sure you have emails from that domain with dates in them
- Check the logs for details on what the script found
- Verify your school's email domain in the
-
Calendar access issues:
- Confirm your Calendar ID is correct by running
testCalendarAccess
- Make sure you have edit permissions for the calendar
- Confirm your Calendar ID is correct by running
-
Date detection issues:
- The script looks for common date formats, but some schools may use unusual formats
- Check the logs to see what content is being processed
- You can add additional date patterns in the
datePatterns
array
- For first-time use, consider increasing
DAYS_TO_LOOK_BACK
to catch older events - Refine the
SEARCH_QUERY
if your school uses multiple email domains - Check the execution logs for detailed information on what's being processed
MIT License - Feel free to modify and share this script!
Contributions are welcome! Please feel free to submit a Pull Request.