Skip to content

Instantly share code, notes, and snippets.

View olifischer's full-sized avatar

Oliver Fischer olifischer

  • Germany
View GitHub Profile
@olifischer
olifischer / CollectNamesAndEmail.js
Created May 13, 2025 07:13
Extract Gmail Contacts to CSV
// Configuration
// Note: Processing ALL emails can still take a long time and may exceed Google Apps Script total execution time limits (max 6 minutes per run for free accounts).
// This script fetches threads in batches of BATCH_SIZE to work around the GmailApp.search limit of 500 results per call.
const BATCH_SIZE = 500; // Maximum number of threads to fetch in a single search call (Gmail limit is 500)
const CSV_FILENAME = 'Gmail_Contacts.csv'; // Name of the CSV file to be created in your Drive.
/**
* Extracts sender names and email addresses from all Gmail threads (excluding Trash and Spam)
* by fetching threads in batches, and saves them into a CSV file in your Google Drive.
*