This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. | |
* |