Created
March 1, 2024 20:03
Revisions
-
CodeLeom created this gist
Mar 1, 2024 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ function logEmailsToSheet() { // Specify the subject line to search for in Gmail var query = 'subject:"Feedback Submission"'; // Access the active spreadsheet and the first sheet var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); // Search Gmail with the given query var threads = GmailApp.search(query); for (var i = 0; i < threads.length; i++) { var messages = threads[i].getMessages(); for (var j = 0; j < messages.length; j++) { var message = messages[j]; // Extract date, sender, subject, and body from each email var date = message.getDate(); var from = message.getFrom(); var subject = message.getSubject(); var body = message.getPlainBody(); // Append the data to the sheet sheet.appendRow([date, from, subject, body]); } } }