Loads a single email message by its ID.
class GmailApp method .getMessageById()
GmailApp is the Apps Script service.
.getMessageById() is the method name you will see after a dot in your code.
What it does
Why it's used
- Load one specific email after you stored its ID in a sheet.
- Re-read a message body for parsing or logging.
Common errors
- Forgetting parentheses on getMessageById. Write GmailApp.getMessageById(), not GmailApp.getMessageById or getMessageById by itself.
- Skipping dots between chained calls. Each step needs a dot, like GmailApp.search('label:inbox').getMessageById().
- Adding spaces where they do not belong. Write GmailApp.getMessageById(), not GmailApp .getMessageById(), GmailApp.getMessageById (), or GmailApp . getMessageById().
- Wrong capitalization. Use GmailApp and getMessageById, not gmailapp or getmessagebyid.
Explore
Related methods
-
.getThreadById()
Loads an email thread by its ID.
-
.search()
Finds Gmail threads that match a search query.
-
.sendEmail()
Sends an email from the user's Gmail account.
-
.getInboxThreads()
Returns email threads from the user's inbox.
-
.getUserLabelByName()
Finds a Gmail label by its name.
More Apps Script
Better Sheets tutorials
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
Related blog posts
Written guides about GmailApp.getMessageById().