GmailApp lets you search your inbox, read message content, and extract metadata like sender, subject, and body. This is useful for processing inbound requests, building email-to-sheet pipelines, or automating follow-ups based on customer replies.
Searching for Messages
Use GmailApp.search(query) with standard Gmail search syntax:
functionreadUnreadFromCustomers(){var threads =GmailApp.search('is:unread from:(@techventures.com OR @deltatech.io OR @innovateco.com)'); threads.forEach(function(thread){var msg = thread.getMessages()[0];// First message in threadLogger.log("From: "+ msg.getFrom());Logger.log("Subject: "+ msg.getSubject()); thread.markRead();// Mark as read after processing});}
Writing Email Data to a Sheet
This example searches for deal-related emails and logs them into a Google Sheet for tracking: