Google app
Gmail
GmailApp scripts can send messages, search threads, apply labels, and read attachments after you approve Gmail access for the project.
Choose a task using GmailStart with an outcome
Tasks that use Gmail
Choose the result first. The service flow shows what this automation connects.
- Gmail Send an email for each row in a Google Sheet
Use one row per person, then let the script send only the rows that have not already been marked as sent.
- Gmail Send an email when a status changes
When someone changes a status dropdown in Google Sheets, email the address on that row, including on newly copied tabs.
- Gmail Save labeled Gmail attachments to Drive
Choose the email threads yourself by adding a Gmail label, then copy their attachments into an existing Drive folder.
- Gmail Label emails from one sender in Gmail
Search your mailbox with GmailApp.search() for messages from one sender address, then call thread.addLabel() so those conversations are easy to find later.
- Gmail Log new emails to a Google Sheet
Search your recent mail and add one row per message to a tab named Email log. A hidden ID column keeps a second run from adding the same message twice.
- Gmail Email a Google Doc as a PDF
Give the script the file ID of a Doc. It makes a PDF copy and emails it as an attachment. The Doc itself is not changed.
- Gmail Email yourself a weekly sheet summary
Run the setup function once. Each Friday the script reads the Orders tab, counts the nonblank rows, totals column C, counts the rows that are not Done, and emails the account that installed it.
- Gmail Email yourself tomorrow’s calendar agenda
A setup function installs one daily trigger for the early evening. Each evening the script reads tomorrow on your main calendar and emails you the list.
- Gmail Run an Apps Script function every day
Run the setup function once, then Apps Script calls the reminder function each day around your chosen hour.
- Gmail Respond to a Google Form submission
Add a small response function, then install a form-submit trigger so each new answer produces a private email summary.
- Gmail Send a confirmation to the form respondent
When the form collects verified email addresses, a form submit trigger can send the person who answered a short thank you that repeats their answers.
- Gmail Check a website and alert when it is down
An hourly trigger fetches one address. The script remembers the last result in a script property, so a long outage produces one alert instead of one every hour.
Snippets
Small pieces for Gmail
Complete functions you can paste and run one at a time.
Object reference
Objects available in Gmail
Open an object when you need to get it, try a common action, or inspect exact method signatures.
- Object reference Gmail thread
A GmailThread holds one Gmail conversation. Reach threads with GmailApp.search() or label.getThreads(), then call getMessages() or addLabel().
- Object reference Gmail message
A GmailMessage is one email inside a Gmail thread. Call getFrom(), getSubject(), getDate(), getPlainBody(), or getAttachments() to inspect that single message.
- Object reference Gmail label
A Gmail label is a tag you can apply to conversations. A script can look one up by name, and can add or remove it from threads.