class GmailApp method .search()

GmailApp is the Apps Script service.

.search() is the method name you will see after a dot in your code.

What it does

Finds Gmail threads that match a search query.

Why it's used

  • Find emails from a client, with an attachment, or from last week.
  • Pull matching threads into a tracker automatically.

Common errors

  • Forgetting parentheses on search. Write GmailApp.search(), not GmailApp.search or search by itself.
  • Skipping dots between chained calls. Each step needs a dot, like GmailApp.search('label:inbox').search().
  • Adding spaces where they do not belong. Write GmailApp.search(), not GmailApp .search(), GmailApp.search (), or GmailApp . search().
  • Wrong capitalization. Use GmailApp and search, not gmailapp or search.

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

Browse the blog