Skip to content

Instantly share code, notes, and snippets.

@danielcranney
Created November 1, 2024 10:19
Show Gist options
  • Save danielcranney/793eb931f7a23d9d3a1f250e8023894a to your computer and use it in GitHub Desktop.
Save danielcranney/793eb931f7a23d9d3a1f250e8023894a to your computer and use it in GitHub Desktop.
newsletter unsubscription tracker / 04 - connect to Google sheet.js
// Logs emails from threads labeled "unsubscribed" to a Google Sheet
function logUnsubscribes() {
var label = GmailApp.getUserLabelByName('unsubscribed'); // Fetch the "unsubscribed" label from Gmail
var threads = label.getThreads(); // Get all threads with this label
var sheet = SpreadsheetApp.open(DriveApp.getFileById('REPLACE_WITH_GOOGLE_SHEET_ID')); // Open the target Google Sheet
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment