Skip to content

Create Google Calendar events from sending yourself a Gmail on a mobile device using Google Apps Script.

Notifications You must be signed in to change notification settings

BigJazzz/events-from-gmail

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

Create Google Calendar events from sending yourself an email

This Google Apps Script allows you to create a Google Calendar event by sending yourself an email in Gmail. Unlike Gmail's current feature to create Google Calendar events, this script allows you to be on a mobile device.

What this script does

You send yourself an email that looks like this:

send yourself an email with google calendar details

...and a Google Calendar event gets created with all the relevant fields filled out:

create google calendar event from email

Main features

  • Switch between U.S. (m/d/y) and non-U.S. (d/m/y) date formats in the subject line of your email
  • Create all-day and multi-day events
  • Invite guests and add to the description of the event by writing in the body of the email (see Optional fields in event below)

Formatting the email

The only required content you need to include in the email is the subject line. The minimum info you need is the event title and the date (separated by a comma). Some examples on what you could write in the subject line:

  • Schedule appointment, 9/3, 3PM: An event with the title "Schedule appointment" gets created on September 3rd at 3:00PM
  • Schedule appointment, 9/3: An all-day event with the title "Schedule appointment" gets created on September 3rd
  • Schedule appointment, 9/3-9/5: A multi-day event with the title "Schedule appointment" gets created from September 3rd to September 5th

Optional fields in event

If you want to invite guests to your event and know their email addresses, you simply write "cc: [email protected], [email protected]" as the first line in the body of the email (multiple emails need to be separated by a comma). To add a description to the event, just write the description in the second line of the email. So if the body of your email looks like this:

cc: [email protected], [email protected]
Need to schedule an appointment with John and Jane

The Google Calendar event will invite [email protected] and [email protected] as guests to your event and "Need to schedule an appointment with John and Jane" gets added to the descriptoin of the event.

Setup

  1. Create a new Google Apps Script project and replace the default code in the editor with the script. Hit ⌘+S to save the script.
  2. Create a Gmail label called "EventsFromEmail" (this is the GMAIL_LABEL variable in line 8). If you call the label something else, just make sure to change this line of the script.
  3. The DEFAULT_EVENT_TIME in line 9 is 30 minutes (change if necessary). Also decide if your date format is "US" or "ROW" (rest of the world) in line 10.
  4. Setup a Gmail filter so that all emails you send to yourself automatically get labeled "EventsFromEmail" and skip the inbox (but still stay unread). The recipient email address should use the + trick in Gmail to setup your Gmail filter. For instance, I set up a filter so that all emails sent to "[email protected]" go to my "EventsFromEmail" label:

  1. Send yourself a test email to make sure the filter works correctly and the email shows up in your "EventsFromEmail" label.
  2. Back in Google Apps Script, select the getEmail function in the toolbar and click "Run" to run the script for the first time.
  3. Click "Allow" when asked to give Google Apps Script permission to access your Gmail and Google Calendar.
  4. You may get a screen saying Google hasn't verified the app. Click "Advanced" and click the link to continue to use the script:

  1. Set up a time-driven trigger so that the getEmail function runs every 10 minutes, 30 minutes, or whatever interval suits you (I set mine to every 15 minutes):

Notes & Caveats

  • If you add a time for the event in the subject line, it needs to have "AM" or PM" appended to the time
  • Events get created based on the timezone setting of your Google Apps Script (which defaults to the timezone of your computer)
  • If you change timezones, you may need to update the appscript.json file with the new timezone you're in. See this Wikipedia article (specifically the "TZ database name" column) for the proper formatting of timezone names.

Tutorials

Read the full write-up here on why I wrote this script and watch the video tutorial below to setup the script:

create google calendar events from gmail

About

Create Google Calendar events from sending yourself a Gmail on a mobile device using Google Apps Script.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%