> You are reading the Docusign Developer Documentation. For clean Markdown of any page, append .md to the page URL.
>
> Documentation indexes by section:
> - APIs and SDKs: https://docusign.docs.buildwithfern.com/docs/llms.txt
> - Platform 101: https://docusign.docs.buildwithfern.com/platform/llms.txt
> - Extension Apps: https://docusign.docs.buildwithfern.com/extension-apps/llms.txt
> - Docusign CLI: https://docusign.docs.buildwithfern.com/docusign-cli/llms.txt
>
> Authentication (OAuth, JWT Grant, M2M): https://docusign.docs.buildwithfern.com/platform/auth
> Webhooks and Connect: https://docusign.docs.buildwithfern.com/platform/webhooks
>
> OpenAPI specifications: https://docusign.docs.buildwithfern.com/openapi.json
> MCP server: https://docusign.docs.buildwithfern.com/_mcp/server

# How to send an envelope with email reminders

> See how to send an envelope with email reminders using the APEX toolkit.

This topic demonstrates how to send an envelope with email reminders using the `Notifications` class in the Apex Toolkit.

## Prerequisites

1. Install the [Docusign eSignature for Salesforce](/docs/salesforce/how-to/apex-toolkit-install)  managed package.
2. Create a subdomain for your Salesforce organization by enabling "My Domain."
3. Select the **Docusign Setup** tab and complete the login step.

## Required data

Running the code in this how-to requires this data:

| Data element         | Description                                                                                                                                                                                                                                                                                              |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Contact ID           | The ID of the Salesforce Contact that will receive the envelope.                                                                                                                                                                                                                                         |
| Salesforce source ID | The Salesforce ID of the object from which the Docusign envelopes will be sent.                                                                                                                                                                                                                          |
| \{TEMPLATE_ID}       | A [GUID](http://guid.one/) value that identifies a Docusign [template](/docs/esign-rest-api/esign101/concepts/templates) that is used to create a Docusign [envelope](/docs/esign-rest-api/esign101/concepts/envelopes). This value is automatically generated by Docusign when the template is created. |

## Step 1. Define a public class and method

Create the class and methods that will contain the code in this example. You can skip this step if you are adding this code to an existing class.

**`Apex`**

```json title="Apex"
public class SendEnvelopeWithReminderController {
  public static void sendEnvelopeMethod(){
  }
}
```

## Step 2. Create the notification definition

Create a  [Notifications](/docs/salesforce/apex-toolkit-reference/notifications.html) object to define the notification settings for all of the envelope’s recipients. The first parameter of the `Notifications` object is set to true to indicate that reminders should be sent to the recipients. The second parameter indicates the number of days that will pass before the first reminder is sent, and the third parameter indicates the number of days that will pass between reminders. The `Notifications` object also allows you to set an expiration date for the envelope and send a reminder before that date.

**`Apex`**

```java title="Apex"
dfsle.Notifications notifySigner = new dfsle.Notifications(
    true, // Indicates that the recipient should be reminded to sign
    2, // Number of days to wait before sending a reminder
    1, // Number of days between reminders
    true, // Whether or not the envelope expires and is voided
    90, // How many days before the envelope expires
    10, // Number of days before expiration to remind the recipient
    false // Placeholder for deprecated field
);
```

## Step 3. Create the envelope definition

Use the [EnvelopeService.getEmptyEnvelope](/docs/salesforce/apex-toolkit-reference/envelopeservice.html) method to create an empty envelope template definition that will be subsequently completed, created, and sent. Specify the Salesforce ID of the record in the [Entity](/docs/salesforce/apex-toolkit-reference/entity.html) parameter that is to be used as the source object for the envelope. Create a [Recipient](/docs/salesforce/apex-toolkit-reference/recipient.html) object for each recipient of the envelope. Once a recipient is created, use the [withRecipients](/docs/salesforce/apex-toolkit-reference/envelope.html) method to add it to the envelope. Create a new [dfsle.Document](/docs/salesforce/apex-toolkit-reference/document.html) using the [dfsle.Document.fromTemplate](/docs/salesforce/apex-toolkit-reference/document.html) method and add it to the envelope. Add your `Notifications` object from the previous step to the envelope with the [withNotifications](/docs/salesforce/apex-toolkit-reference/envelope.html) method.

**`Apex`**

```java title="Apex"
		// Create an empty envelope.
		dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
    	new dfsle.Entity(mySourceId));
 		// The initiating Salesforce entity.

        // We will use a Salesforce contact record as a Recipient here
		// We will use a Salesforce contact record as a Recipient here
		Contact myContact = [SELECT Id, Name, Email FROM Contact WHERE Id = '00xxxxxxxxxxxxxxAR'];

		// Use the Recipient.fromSource method to create the Recipient
		dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
            myContact.Name, // Recipient name
            myContact.Email, // Recipient email
            null, // Optional phone number
            'Signer 1', // Role Name. Specify the exact role name from template
            new dfsle.Entity(myContact.Id)); // Source object for the Recipient

		// Add Recipient to the Envelope
		myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient });

        // myTemplateId contains the DocuSign Id of the DocuSign Template
		dfsle.UUID myTemplateId = dfsle.UUID.parse('8dafxxxx-xxxx-xxxx-xxxx-xxxxxxxx27f7');

		// Create a new document for the Envelope
		dfsle.Document myDocument = dfsle.Document.fromTemplate(
    		myTemplateId, // templateId in dfsle.UUID format
    		'myTemplate'); // name of the template

		// Add document to the Envelope
		myEnvelope = myEnvelope.withDocuments(new List<dfsle.Document> { myDocument });
        // Add notification to the envelope
        myEnvelope = myEnvelope.withNotifications(notifySigner);
```

## Step 4. Send the envelope

Send the envelope using the [EnvelopeService.sendEnvelope](/docs/salesforce/apex-toolkit-reference/envelopeservice.html) method. Set the `sendNow` parameter to `true` to indicate that you want to send the envelope immediately. Setting the `sendNow` parameter to `false` will save the envelope as a draft. The Apex Toolkit does not support sending a draft envelope. To send a draft envelope, you will need to call the [eSignature REST API](/docs/esign-rest-api) outside of the Apex Toolkit.

The accompanying code demonstrates how to send the envelope.

**`Apex`**

```java title="Apex"
		myEnvelope = dfsle.EnvelopeService.sendEnvelope(
    		myEnvelope, // The envelope to send
    		true); // Indicates that the envelope should be sent now
```

## Step 5. Execute your method

To execute your code, go to the [Developer Console](https://help.salesforce.com/s/articleView?language=en_US\&id=sf.code_dev_console.htm\&type=5) in Salesforce, open the **Debug** menu, then select **Open Execute Anonymous Window**. Type the accompanying code in the window and select **Execute**.

> **Note**
>
> View this code on GitHub: [Apex](https://github.com/docusign/code-examples-apex/blob/main/force-app/main/default/classes/SendEnvelopeWithReminderController.cls).

**`Apex`**

```java title="Apex"
SendEnvelopeWithReminderController.sendEnvelopeMethod();
```

## Expected response

If your API call is successful, the recipient should receive an email notification asking them to sign the document in the envelope. After two days, they will begin to receive daily email reminders until the envelope expires in 90 days. You can view the envelope in the Docusign Apps Launcher under **Docusign Envelopes**.

![ApexSendWithEmailReminder.jpg](/_fern-files/_img/ed1f697d08cf852ff7ff9afb3662756488ca9f1f0daeeee69eddc76e8bc1c6db.webp)

## Next steps

* See all available Apex Toolkit [How-to guides](/docs/salesforce/how-to).
* Learn [How to send an envelope](/docs/salesforce/how-to/send-envelope).
* See [How to perform unit testing](/docs/salesforce/how-to/unit-testing) to ensure that you have adequate code coverage.