class GmailApp method .getUserLabelByName()

GmailApp is the Apps Script service.

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

What it does

Finds a Gmail label by its name.

Why it's used

  • Find your Invoices or Leads label before sorting mail.
  • Apply existing labels instead of creating duplicates.

Common errors

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

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

Browse the blog