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

Loads a single email message by its ID.

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

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().

Browse the blog