Skip to content

email: conditional recipients in rendered email metadata #14023

Closed

Description

@juleswg23

We have recently added support for multiple emails rendered from a single document. This next step will allow any/all emails to have conditional recipients.

I am flexible on the format of accepted quarto input, here is a draft of how it might look:

---
title: Email Test Document
author: Charles Teague
format: email
---

The report content. Anything that is here is not part of the email message.

::: {.email}

::: {.subject}
The subject line.
:::

```{python}
import datetime

# Get today's date
today = datetime.date.today()

if today.weekday() < 5:
    recipients = ["test1@test.com", "test2@test.com", "test3@test.com"]
else:
    recipients = ["test4@test.com", "test5@test.com", "test6@test.com"]
```

:::{.recipients}
`{python} recipients`
:::

::: {.email-text}
An optional text-only version of the email message..
:::

The HTML email content. Here you can add code cells, produce images, and write accompanying text.

:::

Any additional report content not part of the email message.

Multiple emails here: #13882

Activity

  1. added
    enhancement
    on Feb 11, 2026
  2. added this to the v1.10 milestone on Feb 12, 2026
  3. juleswg23 commented on Feb 19, 2026

    @juleswg23
    ContributorAuthor

    After discussion with @jonkeane, it would also make sense to be able to pass recipients in the following ways (the first in both in both R and Python).

    ---
    title: Email Test Document
    author: Jules WG
    format: email
    ---
    
    ```{python}
    import datetime
    
    # Get today's date
    today = datetime.date.today()
    
    if today.weekday() < 5:
        recipients = ["test1@test.com", "test2@test.com", "test3@test.com"]
    else:
        recipients = ["test4@test.com", "test5@test.com", "test6@test.com"]
    ```
    
    ::: {.recipients, values=recipients}
    :::
    
    ::: {.recipients}
    Jules@posit.co
    neal@posit.co
    nihara@posit.co
    :::
    
    ::: {.recipients}
    Jules@posit.co, neal@posit.co,  nihara@posit.co
    :::
    

    Edit: This approach (::: {.recipients, values=recipients}) isn't possible because the attribute is preserved as values="recipients" in the HTML, so it contains the literal string "recipients", not the evaluated Python variable value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

emailenhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions