# Generate and Email Your Document

## What You'll Learn

* Generate a document from a Salesforce record page
* Review the generated file in the document list
* Open the email editor from the generated document
* Check recipients, subject, and sender details before sending
* Troubleshoot the most common end-user issues

## What You'll Build

In this tutorial, you will use an `Opportunity` record to generate a quote and email it to a customer.

By the end, you will have:

* One generated quote linked to the `Opportunity`
* One reviewed PDF ready to send
* One outbound email sent from the record page
* One repeatable workflow your team can use every day

**Estimated time:** 10 minutes

## Prerequisites

Before you start, make sure you have:

* Access to an `Opportunity` record page with **Generate Documents (S-Docs)** and **Documents (S-Docs)**
* At least one S-Docs template available in the generation list
* One test `Opportunity` with customer data
* Permission to generate documents and send email from Salesforce
* An admin-configured email template if you expect default subject or recipient values

If the S-Docs components do not appear on the record page, ask your Salesforce admin to complete [Add S-Docs Lightning Components to a Record Page](/quick-start/document-generation/add-s-docs-lightning-components-to-a-record-page.md).

{% stepper %}
{% step %}

### Step 1: Open the record where you want to send the document

Start on the Salesforce record that holds the customer data.

For this example, use an `Opportunity`.

1. Open Salesforce.
2. Go to **Opportunities**.
3. Open one test opportunity.
4. Confirm the record has the customer and quote details you want to send.

You are now on the record page where the full generate-and-send workflow happens.
{% endstep %}

{% step %}

### Step 2: Generate the document

Use the S-Docs generation panel at the top of the record page.

You may see it labeled **Generate Documents (S-Docs)** or a custom title such as `Templates to Generate`.

1. Find the S-Docs generation panel.
2. Select the template you want, such as a quote template.
3. Click **Generate**.
4. Wait for the success notification if **Notify User** is enabled.

This creates the document from the record data.

{% hint style="info" %}
If your page is configured to open previews automatically, the generated document may open right away.
{% endhint %}
{% endstep %}

{% step %}

### Step 3: Confirm the document appears in the document list

After generation, the file should appear in the S-Docs document list on the same page.

{% hint style="warning" %}
Note: You may need to refresh the page to ensure the document is visible in the Generated Documents component.&#x20;
{% endhint %}

You may see it labeled **Documents (S-Docs)** or a custom title such as `Generated Documents`.

1. Scroll to the S-Docs document list.
2. Look for the new file you just generated.
3. Confirm the file name matches the document you expected.
4. Confirm the document is tied to the same `Opportunity`.

This confirms the document was created and linked to the record.
{% endstep %}

{% step %}

### Step 4: Review the document before you send it

Check the file before you email it.

1. Open the generated document from the list.
2. Review key details such as customer name, amount, and date.
3. Close the preview when you are done.

This helps you catch record-data issues before the customer sees the document.
{% endstep %}

{% step %}

### Step 5: Open the email editor

Use the email action from the generated document.

Depending on your page setup, this can appear as an **Email** action on the document row or as an action after you select the document.

1. Find the generated document in the list.
2. Open the email action for that document.
3. Wait for the email editor to load.

If your admin enabled automatic email open, the editor may appear right after generation instead.
{% endstep %}

{% step %}

### Step 6: Review the email details and send

Check the message before you send it.

1. Confirm the **To** address is correct.
2. Confirm the **Subject** matches the document you are sending.
3. Confirm the **From** address matches your team's process.
4. Review the email body.
5. Make edits if your org allows them.
6. Click **Send**.

What you just did:

* Used the generated document as the source for the outbound email
* Confirmed recipient and sender details before sending
* Completed the full workflow without leaving the record page
  {% endstep %}

{% step %}

### Step 7: Verify the result on the record

Do one quick check after sending.

1. Return to the `Opportunity` record if the editor closed.
2. Confirm the generated document still appears in the document list.
3. Confirm the workflow completed without an error.
4. If needed, check the record's **Files** related list.

You now have a complete record-page workflow for generating and emailing S-Docs output.
{% endstep %}
{% endstepper %}

## Common Issues and Solutions

<details>

<summary>I do not see any templates in the generation panel</summary>

Check these items:

* The page includes **Generate Documents (S-Docs)**
* Your admin added templates to the component setup
* The template matches the same base object as the record
* You have access to the template

If the panel is empty, ask your Salesforce admin to review [Configure Document Generation](/quick-start/getting-started/configure-document-generation.md).

</details>

<details>

<summary>The document generated, but I cannot find it</summary>

Check these items:

* Refresh the record page
* Confirm the page includes **Documents (S-Docs)**
* Confirm the generation finished without an error
* Check the record's **Files** related list

</details>

<details>

<summary>The email editor opens, but the recipient is blank</summary>

Check these items:

* The source record contains the expected email address
* Your admin configured email defaults on the template
* You can type the address manually if your org allows it

If email defaults are expected but missing, ask your admin to review [Configure Email Template Settings](/quick-start/template-building/customize-template-settings-email.md).

</details>

<details>

<summary>I cannot send the email</summary>

Check these items:

* All required email fields are completed
* Your Salesforce user can send email
* The sender option configured by your admin is valid
* Your org did not apply a sending restriction that blocks the address

</details>

<details>

<summary>The document content looks wrong</summary>

Check these items:

* The source record has the correct data
* You generated from the correct template
* You opened the newest generated file

If the layout or default values are wrong, share the issue with the template owner or Salesforce admin.

</details>

## What You've Learned

✅ Generated a document from a Salesforce record page\
✅ Confirmed the file appeared in the S-Docs document list\
✅ Opened the email editor from the generated document\
✅ Reviewed recipient, subject, and sender details\
✅ Sent the document without leaving the record page

## Next Steps

* Use [Configure Email Template Settings](/quick-start/template-building/customize-template-settings-email.md) if your team wants email defaults.
* Use [Configure Template Settings: Document Generation](/quick-start/template-building/customize-template-settings-document-generation.md) if your team wants cleaner file names and save behavior.
* Use [Add S-Docs Lightning Components to a Record Page](/quick-start/document-generation/add-s-docs-lightning-components-to-a-record-page.md) if your admin still needs to set up the page.

## Practice Exercise

Send one test quote from an `Opportunity` record.

1. Open a test opportunity.
2. Generate one quote document.
3. Review the file.
4. Email it to yourself.
5. Confirm the email arrives with the expected subject and attachment.

Bonus challenges:

* Generate a second template from the same record.
* Send the document to a different test address.
* Update the `Opportunity`, regenerate the file, and compare the result.


---

# 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/quick-start/getting-started/generate-and-email-your-document.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.
