# How To: Sending Generated Documents via Email

Once documents are generated using the **Generate Documents (S-Docs)** Lightning Web Component, they are automatically listed in the **Documents (S-Docs)** component on the record page. From this component, users can select one or multiple generated documents and send them together in a single email.

### Sending Documents Using an Email Template

The **Documents (S-Docs)** LWC allows you to predefine an email/HTML template that will be used when sending documents.

To use a specific email template:

* Specify the **Email Template Name** in the component configuration (as shown in the screenshot below).
* The template must be an **HTML Email Template** available for the object.

{% hint style="info" %}
**Considerations:**

* Only **one** email/HTML template can be configured per component.
* Multiple email templates cannot be used simultaneously.
* The configured template will automatically load when sending documents from the component.
  {% endhint %}

### Sending Documents Without a Predefined Template

Configuring an email template is optional.

If no email template is specified, select the “No Template” option.

* The email editor will still open when you send documents.
* You can manually customize the email at the time of sending.
* This provides flexibility for users who need to customize emails on a case-by-case basis.

### Automatically Opening the Email Editor After Document Generation

When generating documents using the **Templates to Generate (S-Docs)** LWC, you can configure the system to automatically open the email editor immediately after document generation.

To enable this behavior:

* Check the **Automatically Open Email Editor option** within the **Documents** component.

This allows users to:

* Generate documents
* Immediately attach them to an email
* Send the email without navigating away from the record page

### Recommended Configuration and Usage

**Configuration Steps :**

{% stepper %}
{% step %}

#### Click Edit Page in Lightning App Builder.

{% endstep %}

{% step %}

#### Select the Documents (S-Docs) component.

{% endstep %}

{% step %}

#### In the component properties:

* Choose an HTML Email Template from the dropdown list.
  {% endstep %}

{% step %}

#### Click Save and activate the page.

{% endstep %}
{% endstepper %}

**Sending Emails :**

{% stepper %}
{% step %}

#### Open the record page.

{% endstep %}

{% step %}

#### Select one or more generated PDF documents from the Documents (S-Docs) component.

{% endstep %}

{% step %}

#### Click Send.

{% endstep %}

{% step %}

#### Review and modify the email content if needed.

{% endstep %}

{% step %}

#### Click Send to deliver the email with the selected documents attached.

{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Considerations:**

* An email address is required in the To: field prior to sending
* The To:, CC:, Subject, and Body can be pulled directly from the template.
  {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/automation-and-document-lifecycle/workflows/sending-generated-documents-via-email-s-docs-lwc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
