Skip to content

Instantly share code, notes, and snippets.

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