Logo
  • Home
  • Templates
  • Blog
  • YouTube
  • Notion Academy
Marketplace
Complete Guide: Syncing Gmail Emails to Notion

Complete Guide: Syncing Gmail Emails to Notion

Table of Content

  • Syncing Gmail to Notion - Complete Guide
  • Phase 1: Notion API Setup
  • 1. Create a Notion Integration (API Key)
  • 2. Create the Notion Database
  • 3. Share the Database with the Integration
  • Phase 2: Google Apps Script Setup and Deployment
  • 4. Create the Google Apps Script Project
  • 5. Configure the Script Properties
  • 6. Run and Authorize the Script
  • 7. Set up the Time-Driven Trigger
icon
Support My Work

Syncing Gmail to Notion - Complete Guide

This guide provides the complete, step-by-step process for connecting Gmail to Notion using Google Apps Script (GAS).

Phase 1: Notion API Setup

1. Create a Notion Integration (API Key)

  1. Go to the Notion Integrations Page.
  2. Click + New integration.
  3. Give it a name (e.g., "Gmail Sync").
  4. Associate it with the workspace you are using.
  5. Under "Content Capabilities," make sure Read content and Insert content are checked.
  6. Click Submit.
  7. IMPORTANT: On the next screen, copy the Internal Integration Token and save it securely. This is your NOTION_API_KEY.

2. Create the Notion Database

  1. In your Notion workspace, create a new page and turn it into a Database (Table View).
  2. Name the database (e.g., "Email Inbox").
  3. Property Name
    Property Type
    Notes
    Subject
    Title
    This will hold the Email Subject. (Default column)
    Date
    Date
    This will hold the received date.
    Link to Email
    URL
    This will hold the direct Gmail URL to the message.
    Sender
    Text
    The email address of the sender.
    Snippet
    Text
    A short preview of the email content.
    Status
    Select
    Ensure “Status” select option “📥 Inbox”

3. Share the Database with the Integration

  1. Open the Notion Database page you just created.
  2. Click the ... (three dots) menu in the top right corner.
  3. Click Add connections at the bottom of the menu.
  4. Search for and select the integration you created in Step 1 (e.g., "Gmail Sync").
  5. IMPORTANT: Once the integration is connected, copy the Database ID from the URL. The URL format is https://www.notion.so/{workspace_name}/{**DATABASE_ID**}?v=.... Copy the 32-character string that appears immediately after the workspace name. This is your NOTION_DATABASE_ID.

Phase 2: Google Apps Script Setup and Deployment

4. Create the Google Apps Script Project

  1. Go to script.google.com and click + New project.
  2. Rename the project (e.g., "Gmail to Notion Sync").
  3. Replace the default Code.gs content with the script provided in the next file block.

5. Configure the Script Properties

The script uses script properties to securely store your Notion keys and settings.

  1. In the Apps Script editor, click the Settings icon (⚙) on the left sidebar.
  2. Scroll down to Script properties.
  3. Click + Add script property and enter the following three properties, using the values you copied from Notion:
  4. Property Key
    Property Value
    Description
    NOTION_API_KEY
    secret_...
    Your 32-character Integration Token.
    NOTION_DATABASE_ID
    a9b2c...
    Your 32-character Database ID.
    GMAIL_SEARCH_QUERY
    is:starred OR label:"Send to Notion"
    The Gmail query to find emails.
    SYNC_LABEL_NAME
    Notion Synced
    The label the script will apply after syncing.
  5. Click Save script properties.

6. Run and Authorize the Script

  1. Go back to the Editor icon (<>) on the left sidebar.
  2. ‣
    Code.gs
  3. Select the syncEmailsToNotion function from the dropdown menu (it should be selected by default).
  4. Click the Run button.
  5. The first time you run it, you must grant permissions:
    • Click Review permissions.
    • Select your Google Account.
    • You will see a warning screen; click Advanced and then Go to “Project Name”
    • (unsafe).

    • Click Allow to grant access to Gmail, external connection services (UrlFetchApp), and configuration (PropertiesService).

7. Set up the Time-Driven Trigger

This step ensures the script runs automatically (e.g., every 15 minutes).

  1. In the Apps Script editor, click the Triggers icon (⏰) on the left sidebar.
  2. Click + Add Trigger in the bottom right.
  3. Set the following options:
    • Choose which function to run: syncEmailsToNotion
    • Choose deployment to run: Head
    • Select event source: Time-driven
    • Select type of time-based trigger: Hour timer (or Minutes timer)
    • Select hour of day/interval: Every 15 minutes (Recommended)
  4. Click Save.

The setup is complete! The script will now run on the schedule you set.

🎁 Are you founder or startup? Get 30 Notion Plus & AI for FREE with Partner link: https://affiliate.notion.so/experience

The Notion Experience

Newsletter

Contact

About

© 2025 The Notion Experience. All rights reserved.

FacebookXLinkedIn