---
title: "List Emails"
description: "List Gmail messages with optional search, labels, and paging."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/gmail/list-emails"
---
# List Emails

> List Gmail messages with optional search, labels, and paging.

<block-meta block="Yes" capability="Gmail" channels="Any" folder="google/gmail" group="Gmail" groupTo="/build/workflows/blocks/gmail" icon="i-lucide-list" pipe="Value" scope="Any" service="Google" tool="Yes" type="google.gmail.list_emails">



</block-meta>

**List Emails** returns message and thread ids from the connected Gmail mailbox. It does not return full bodies. Follow with [Get Email](https://docs.vettero.com/build/workflows/blocks/gmail/get-email) for one message, or [Get Thread](https://docs.vettero.com/build/workflows/blocks/gmail/get-thread) for the conversation.

Search uses the same syntax as the Gmail search box. Type a query in one line and insert context with `{{ }}` (for example `from:{{ args.email }} newer_than:7d`).

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Search query (optional)
      </strong>
    </td>
    
    <td>
      Gmail search string. Liquid template, for example <code>
        from:{{ args.email }} is:unread
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Label IDs (optional)
      </strong>
    </td>
    
    <td>
      Comma-separated label ids, for example <code>
        INBOX,UNREAD
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Max results
      </strong>
    </td>
    
    <td>
      Page size, 1–500. Default <strong>
        20
      </strong>
      
       if empty
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Page token (optional)
      </strong>
    </td>
    
    <td>
      <code>
        nextPageToken
      </code>
      
       from a previous list
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Include spam and trash
      </strong>
    </td>
    
    <td>
      When on, spam and trash can appear in results
    </td>
  </tr>
</tbody>
</table>

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after the list returns
    </td>
  </tr>
</tbody>
</table>

## Pipe schema

The next block reads this on the data pipe (`pipe.value`):

<table>
<thead>
  <tr>
    <th>
      Key
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        messages
      </code>
    </td>
    
    <td>
      list
    </td>
    
    <td>
      Each item has <code>
        id
      </code>
      
       (message id) and <code>
        threadId
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        nextPageToken
      </code>
    </td>
    
    <td>
      text
    </td>
    
    <td>
      Pass to the next list for the following page
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        resultSizeEstimate
      </code>
    </td>
    
    <td>
      number
    </td>
    
    <td>
      Approximate match count (may not be exact)
    </td>
  </tr>
</tbody>
</table>

## Use case

- Find unread inbox mail, then get each message and write a [table](https://docs.vettero.com/data/tables) row.
- Page with `nextPageToken` until it is empty when you need more than one page.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
