search

This block is part of the imap group and was last modified in core v15.0.1.

search v15.0.1

Finds messages in a mailbox and returns their UIDs, newest first. Wire the UIDs into imap fetch to read them. Every criterion that is filled must match.

In pins 19 + flow
  • flow
    flow
  • connection required
    imapconnection
  • mailbox
    value

    Mailbox to search. Defaults to INBOX.

    Default INBOX

  • unseen only
    condition

    Only messages not yet marked read.

    Default false

  • flagged only
    condition

    Only starred / flagged messages.

    Default false

  • answered only
    condition

    Only messages marked answered.

    Default false

  • from
    value

    Substring of the From header.

  • to
    value

    Substring of the To header.

  • subject
    value

    Substring of the Subject header.

  • text
    value

    Substring anywhere in the message, headers included.

  • body
    value

    Substring of the body only.

  • since
    value

    Arrived on or after this date. ISO date, RFC 3339, dd-mm-yyyy or epoch.

  • before
    value

    Arrived before this date (exclusive).

  • larger than bytes
    number

    Only messages larger than this many bytes.

  • smaller than bytes
    number

    Only messages smaller than this many bytes.

  • header name
    value

    Match one header, e.g. List-Id. Needs header value.

  • header value
    value

    Substring the named header must contain.

  • uid after
    number

    Only uids greater than this : pass the highest uid handled last run to poll incrementally.

  • limit
    number

    Keep at most this many uids after ordering. 0 keeps all.

    Default 0

  • newest first
    condition

    Order uids newest first (default). Off orders oldest first.

    Default true

Out pins 8 + flow
  • flow
    flow
  • connection
    imapconnection
  • success
    condition
  • error
    value
  • uids
    array
  • count
    number
  • uid validity
    number
  • uid next
    number
  • messages in mailbox
    number

Runs UID SEARCH in mailbox (default INBOX) and outputs uids[] (numbers, newest first unless newest_first=false), count, uid_validity, uid_next and messages (the mailbox total). Criteria are ANDed: unseen/flagged/answered (conditions), from/to/subject/text/body (substring, case-insensitive, as the server matches), since/before (arrival date; before is exclusive; ISO date, RFC 3339, dd-mm-yyyy or epoch), larger/smaller (bytes), header_name+header_value, and uid_after : uids strictly greater than a remembered cursor, the incremental-poll criterion. limit cuts the list AFTER ordering, so limit 10 is the ten newest. Polling pattern: remember the highest uid you handled together with uid_validity; next run pass uid_after=that uid, and if uid_validity changed, the server reset the mailbox and your cursor means nothing : start over. A search that matches nothing is success=true with count 0. Suppressed in a simulation.

find emails
unread
imap search
poll inbox

A typical wiring for search: a function trigger starts the flow; move messages feeds the connection pin; the flow out pin feeds debug.

Studio canvas example for the search block: typical wiring for search.

Version history

Introduced in v15.0.1.


Back to imap Return to the main group to view all sub-groups Back to imap Return to the group to view all blocks within this group