Created
November 1, 2024 10:20
-
-
Save danielcranney/9fa14d9535f2ee7df20ce01d6f149a59 to your computer and use it in GitHub Desktop.
newsletter unsubscription tracker / 06 - read the contents of the emails.js
This file contains 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
// 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(); | |
messages.forEach(function(message) { | |
var body = message.getBody(); // Get the body content of the email | |
var email = extractEmail(body); // Extract the email from the message body | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment