SelfscribeDownloadOpen the app

Letter to a list

Write one letter; each person gets their own copy with their details filled in.

Document · Simple · uses mail merge, print

Edit it in the playgroundRead the file

What it shows

Write one letter and send it to everyone on a list.

What you learn

A letterhead and an address block, the paper and a page footer, fields like {{name}} filled from a table, a sentence that changes with the person, a signature line.

Try this

  • Step through the tenants with ‹ › over the page, then press Merge… for one letter each.
  • Change Mr Nowak's access from no to yes, and his letter promises a call from a member of staff.
  • Delete set merge tenants, and the letter is to one person again, with the values from the set lines.
examples/letter.self · 127 lines
~~~ selfscribe
# Lesson: Write one letter and send it to everyone on a list.
# You learn: a letterhead and an address block, the paper and a page footer, fields like {{name}} filled from a table, a sentence that changes with the person, a signature line.
# Try this: step through the tenants with ‹ › over the page, then press Merge… for one letter each.
# Try this: change Mr Nowak's access from `no` to `yes`, and his letter promises a call from a member of staff.
# Try this: delete `set merge tenants`, and the letter is to one person again, with the values from the `set` lines.
# summary: Write one letter; each person gets their own copy with their details filled in.
# category: forms
# tags: document, simple, work
# uses: mail merge, print
use data
set title Letter to a list
# ---- The paper, the look, the language and a footer on every page (left | centre | right) --
set page A4 portrait margins normal
set style paper
set font Literata
set heading-font Figtree
set lang en-GB
# keep: each line break you type stays a line break, as an address needs.
set linebreaks keep
set footer Ashcombe Housing Co-operative Ltd · Registered society no. 31207R | | Page {page} of {pages}

# ---- Mail merge: one letter for each row of the tenants table at the end ------------------
# Each {{field}} in the letter takes that row's value. The `set` lines are what each field
# shows outside a merge, as in the gallery: the first tenant's letter.
set merge tenants
set name     Mr Tomasz Nowak
set greeting Dear Mr Nowak
set flat     Flat 2
set street   Ashcombe Court, 12 Vale Road
set town     Bristol BS3 4QT
set access   no
inline {{_}}                 -> var

# ---- Colours, each with its shade for dark pages ---------------------------------------
palette
  brand  #2f5d50  dark #8fd1bd
  rule   color-mix(in srgb, var(--brand) 35%, transparent)

# ---- The letterhead: "from Sender", then "details a | b | c" -----------------------------
line   from _         -> div.lt-from     { font: 700 1.45em/1.1 var(--doc-font-heading); color: var(--brand); letter-spacing: -0.01em }  as lt-from
line   details _      -> div.lt-details  split "|" span.lt-detail  { display: flex; flex-wrap: wrap; gap: 0.1em 1.1em; margin: 0.35em 0 2.6em; padding-bottom: 0.8em; border-bottom: 2px solid var(--rule); font: 0.78em/1.5 var(--doc-font-ui); opacity: 0.85 }  as lt-details

# ---- "::: to … :::" the address; "date …", "ref …" and "Re: …" under it --------------------
block  ::: to ... :::  -> address.lt-to  { font-style: normal; line-height: 1.45; margin: 0 0 1.6em }  as lt-to
line   date _         -> p.lt-date       { text-align: right; margin: 0 0 1.4em }  as lt-date
line   ref _          -> p.lt-ref        { margin: 0 0 0.2em; font: 0.82em var(--doc-font-ui); opacity: 0.7 }  as lt-ref
line   Re: _          -> p.lt-subject    { margin: 0.4em 0 1.2em; font: 700 1em/1.4 var(--doc-font-heading) }  as lt-subject

# ---- The sign-off: "signed Name" leaves room for a pen signature above the name ----------
line   signed _       -> p.lt-signed     { margin: 3.4em 0 0; padding-top: 0.3em; max-width: 16em; border-top: 1px solid var(--rule); font-weight: 600 }  as lt-signed
line   role _         -> p.lt-role       { margin: 0; font-size: 0.9em; opacity: 0.75 }  as lt-role
line   enc _          -> p.lt-enc        { margin-top: 2.4em; font-size: 0.85em; opacity: 0.75 }  as lt-enc
~~~
from Ashcombe Housing Co-operative
details 14 Vale Road, Bristol BS3 4QT | 0117 496 0832 | office@ashcombe.example | Office open Mon–Thu, 10:00–15:00

::: to
{{name}}
{{flat}}, {{street}}
{{town}}
:::

date 2 December 2026

ref Our ref: AC/ROOF/26-14
Re: Roof replacement at Ashcombe Court, 18 January to 26 February 2027

{{greeting}},

We are writing to let you know that the roof of Ashcombe Court will be replaced this winter. The work was agreed at the general meeting on 14 October, and the contract has now been signed with Hartley & Moss Roofing.

Scaffolding goes up on Monday 18 January and should come down by Friday 26 February. Work takes place on weekdays between 08:00 and 17:00. There will be no work at weekends or on 1 February, the day of the boiler inspection.

What this means for {{flat}}:

- The front path will be covered by a walkway for the whole six weeks. It stays open and lit.
- Please keep windows on the top floor closed while the roofers are working above them.
- Bin collection moves to the side gate on Ferris Lane from 18 January.

{{#if access}}You told us last year that you would like help with access. A member of staff will call you before 11 January to talk through the walkway and anything else you need.{{else}}If you or anyone in your home needs help getting in and out during the work, please tell us by 11 January.{{/if}}

There is no extra charge to members. The cost is met from the repairs reserve, as set out in the enclosed summary.

If you have any questions, please call the office or come to the drop-in on Wednesday 13 January, 18:00 to 19:30, in the community room.

Yours sincerely,

signed Joanna Whitlock
role Secretary, on behalf of the management committee

enc Enclosed: schedule of works; summary of costs from the repairs reserve.

{{#unless email}}
---page---

## Who it goes to

One row is one letter. The table is the merge's list, so no letter prints it.
{{/unless}}

```data tenants as table title "Who gets a letter" columns name, flat, access, email
name, greeting, flat, street, town, access:choice(yes|no), email:url
Mr Tomasz Nowak, Dear Mr Nowak, Flat 2, "Ashcombe Court, 12 Vale Road", Bristol BS3 4QT, no, mailto:t.nowak@example.com
Ms Grace Adeyemi, Dear Ms Adeyemi, Flat 5, "Ashcombe Court, 12 Vale Road", Bristol BS3 4QT, yes, mailto:grace.adeyemi@example.com
Mr and Mrs Hollis, Dear Mr and Mrs Hollis, Flat 7, "Ashcombe Court, 12 Vale Road", Bristol BS3 4QT, no, mailto:hollis.family@example.com
Dr Aisha Khan, Dear Dr Khan, Flat 9, "Ashcombe Court, 12 Vale Road", Bristol BS3 4QT, yes, mailto:aisha.khan@example.com
Mr Rhys Llewellyn, Dear Mr Llewellyn, Flat 11, "Ashcombe Court, 12 Vale Road", Bristol BS3 4QT, no, mailto:rhys.l@example.com
```

{{#unless email}}
## How it's made

- The letterhead is two lines of your own, `from` and `details`, and the address is a `::: to` block. `set linebreaks keep` keeps each line of the address on its own line.
- Each `{{name}}`, `{{flat}}` or `{{greeting}}` is a field. With `set merge tenants`, it takes its value from a row of the table, one letter for each row. ‹ › over the page steps through them.
- The paragraph about access is chosen by an `#if access` marker in double braces, with an `else` for everyone else.
- Merge… leaves the table out of the letters, and this part too: it sits between `#unless email` and `/unless` markers, and every tenant has an email. `set page`, `set style paper` and `set footer` give each letter its paper, its look and a footer.

## Try it yourself

1. Add a row `Ms Nadia Haddad, Dear Ms Haddad, Flat 12, "Ashcombe Court, 12 Vale Road", Bristol BS3 4QT, no, mailto:nadia.h@example.com` to the table. Step through the letters with ‹ ›, and there is one more.
2. Change Mr Nowak's access from `no` to `yes`. His letter now promises a call from a member of staff.
3. Change the date line to `date 9 December 2026`. Every letter carries the new date.
4. Change `signed Joanna Whitlock` to your own name. The signature line follows.

Next: *Certificates* prints one page for each name on a list. *Client statements* fills each copy with totals.
{{/unless}}