> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hexclave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SendEmailOptions

> Reference for the SendEmailOptions type used with the sendEmail method.

This is a detailed reference for email-related types in Hexclave. If you're looking for a more high-level overview, please refer to our [guide on the email system](https://docs.hexclave.com/guides/apps/emails/overview.md).# `SendEmailOptions`Options for sending emails via the `sendEmail` method on `HexclaveServerApp`.## Table of ContentsSendEmailOptions Table of Contents<pre />## RecipientsYou must provide exactly one of `userIds` or `allUsers`.

\<details>

\<summary>`sendEmailOptions.userIds`
          
            
            sendEmailOptions</summary>

      

An array of user IDs that will receive the email. All users must exist in your Hexclave project. Cannot be used together with `allUsers`.

Type Definition

\`typescript declare const userIds: string[]; `

\</details>



\<details>

\<summary>`sendEmailOptions.allUsers`
          
            
            sendEmailOptions</summary>

      

Set to `true` to send the email to all users in the project. Cannot be used together with `userIds`.

Type Definition

\`typescript declare const allUsers: true; `

\</details>

## ContentYou must provide exactly one of `html`, `templateId`, or `draftId`.

\<details>

\<summary>`sendEmailOptions.html`
          
            
            sendEmailOptions</summary>

      

Custom HTML content for the email. Cannot be used together with `templateId` or `draftId`.

Type Definition

\`typescript declare const html: string; `

\</details>



\<details>

\<summary>`sendEmailOptions.templateId`
          
            
            sendEmailOptions</summary>

      

ID of the email template to use. Cannot be used together with `html` or `draftId`.

Type Definition

\`typescript declare const templateId: string; `

\</details>



\<details>

\<summary>`sendEmailOptions.draftId`
          
            
            sendEmailOptions</summary>

      

ID of an email draft to send. Cannot be used together with `html` or `templateId`.

Type Definition

\`typescript declare const draftId: string; `

\</details>

## Options

\<details>

\<summary>`sendEmailOptions.themeId`
          
            
            sendEmailOptions</summary>

      

A string ID for a custom theme, `null` for no theme, or `false` to use the default theme.

Type Definition

\`typescript declare const themeId: string | null | false | undefined; `

\</details>



\<details>

\<summary>`sendEmailOptions.subject`
          
            
            sendEmailOptions</summary>

      

Optional email subject line. If you use a template, this overrides the template's default subject.

Type Definition

\`typescript declare const subject: string | undefined; `

\</details>



\<details>

\<summary>`sendEmailOptions.notificationCategoryName`
          
            
            sendEmailOptions</summary>

      

Optional notification category name for user preferences. Users can opt in or out of specific categories through their account settings.

Type Definition

\`typescript declare const notificationCategoryName: string | undefined; `

\</details>



\<details>

\<summary>`sendEmailOptions.scheduledAt`
          
            
            sendEmailOptions</summary>

      

Optional date to schedule the email for. If not provided, the email is sent immediately.

Type Definition

\`typescript declare const scheduledAt: Date | undefined; `

\</details>



\<details>

\<summary>`sendEmailOptions.variables`
          
            
            sendEmailOptions</summary>

      

Optional variables to substitute in the template. Only used when `templateId` is provided.

Type Definition

\`typescript declare const variables: Record<string, unknown> | undefined; `

\</details>

## UsageChoose a content method (`html`, `templateId`, or `draftId`) and a recipient method (`userIds` or `allUsers`):> [tab] Custom HTML
>
> Provide custom HTML directly:
>
> ```typescript theme={null}
> await hexclaveServerApp.sendEmail({
>   userIds: ["user-id-1"],
>   subject: "Hello!",
>   html: "<h1>Welcome</h1><p>Thanks for signing up!</p>",
> });
> ```> [tab] Template
>
> Use a template with variable substitution:
>
> ```typescript theme={null}
> await hexclaveServerApp.sendEmail({
>   userIds: ["user-id-1"],
>   templateId: "welcome-template",
>   variables: {
>     userName: "John Doe",
>     activationUrl: "https://app.com/activate/token123",
>   },
> });
> ```> [tab] Draft
>
> Send from a saved email draft:
>
> ```typescript theme={null}
> await hexclaveServerApp.sendEmail({
>   allUsers: true,
>   draftId: "my-draft-id",
> });
> ```> [tab] Scheduled
>
> Schedule an email for later delivery:
>
> ```typescript theme={null}
> await hexclaveServerApp.sendEmail({
>   userIds: ["user-id-1"],
>   templateId: "weekly-digest",
>   scheduledAt: new Date("2025-01-15T09:00:00Z"),
> });
> ```> [!NOTE]
>
> The `notificationCategoryName`, `themeId`, `scheduledAt`, and `variables` properties work independently
> with any content method.
