I’m working on a Google Apps Script that helps me identify the very first email thread in my Gmail inbox and then extract the date of its initial message. My goal is to accurately determine when the earliest conversation was started. I would appreciate guidance on the correct method to obtain this date using the Gmail service in Apps Script. Below is an updated example of my approach. I’m interested in any suggestions for improving the script or if there’s an alternate, more efficient method to achieve this.
var inboxThreads = GmailApp.getInboxThreads(0, 1);
var earliestThread = inboxThreads[0];
var initialMsg = earliestThread.getMessages()[0];
Logger.log(initialMsg.getDate());