This document will explain how to create S-Docs HTML email templates in the template editor. For a more in-depth explanation on how to create your first S-Docs template, click here.

Before emailing an S-Doc (a PDF, DOC, etc. generated in S-Docs), you can choose an S-Doc email template to automatically fill out the email body, subject line, and To/CC/BCC fields. To do this, simply create a new S-Doc template and choose HTML for the Template Format.

Then, enter the contents of the email body in the template editor using merged fields, SOQL queries, custom HTML code, etc. as you would in any other template.

Finally, set the subject line and the To/CC/BCC fields in the Email Settings tab of the template editor. Make sure to use only one set of brackets instead of two in any merge fields placed in the fields on this tab! (e.g. use {!Contact.Email} instead of {{!Contact.Email}}.) Click Save. That's it! You can now use this email template to send pre-populated emails from S-Docs.

To use your new email template when you're emailing S-Docs, simply select this template in addition to any other S-Doc you'd like to attach to the email.

Note: If you have specified a default email address, subject line, etc. in the Email Settings Tab when editing your HTML template, and another default email address, subject line, etc. in the Email Settings tab of another template (say a DOC or a PDF) that you are attaching to this email, S-Docs will ignore the email info in the non-HTML template(s) and only use the email info specified in the HTML email template.

Generate the docs by clicking Next Step, then click Email Selected Docs.

This opens up the email screen. As you can see below, S-Docs used the HTML email template to create a custom email to send to the specified contact, and attached the other document (the PDF) to the email. To choose additional recipients for your email, select an email address from the Contact Quick Pick drop-down menu, or search for a Contact’s email address in the Contact/User Lookup field. If you search for and select a Contact, their email address will be added to the "To" field, as well as the Contact Quick Pick list. Feel free to move these email addresses to CC or BCC, and type in a subject and a body as you would a normal email.

Alternatively, if you know the email addresses of the people you’d like to send the document(s) to, you can just type them into the To, CC, and BCC fields.

Email Failure Troubleshooting

By default, S-Docs links outbound emails to the contact record with a matching email address; Salesforce requires this linkage. If you try to send an email to an email address that is not listed under any Contact record in your org, S-Docs will attempt to link it to a single dummy contact record called "No Contact Record." This contact record is created automatically by the S-Docs package to handle this linkage, and is immediately deleted once the email is sent.

If your org has implemented validation rules that require additional contact fields to be completed, then the S-Docs package will not be able to create this contact record. In this case, there are two main options.

Option 1 (Recommended)

Create a before insert, before update Apex trigger on the Contact object that automatically changes the fields on the No Contact Record that S-Docs creates so that your validation rules are not triggered. For example, the trigger might look like this if your validation rules prevent the contact field "This_Cannot_Be_Null__c" from being null:

trigger ContactFirstName on Contact (before insert, before update) {
    for (Contact c : trigger.new) {
        if (c.LastName == 'No Contact Record') {
            c.This_Cannot_Be_Null__c = 'some non-null value';
        }
    }
}

With this option, S-Docs will be able to create and delete the No Contact Record, and the email will be sent and logged in Activity History on the base object record.

Option 2

Create the S-Docs No Contact Record manually with all of the fields filled in that are required by your validation rules. The fields that S-Docs requires should be filled in as follows:
First Name: Not Required. We recommend writing S-Docs to avoid confusion.
Last Name: No Contact Record
Email Address: this.email@is.invalid
You then need to add the following parameter to the end of your S-Docs button: &useExistingNoContactRecord=true
Note: This option is not recommended, as the email will not be logged in Activity History on the base object record.

Sandbox Deliverability

If you are testing S-Docs in a sandbox org and emails are not being delivered, you should check Setup > Email Administration > Deliverability, and check that "Access to Send Email" is set to "All email." By default, Salesforce turns off outbound email access when a sandbox is created to reduce the risk of inadvertently sending emails to contacts during development and testing. Be aware that this change effects the entire sandbox and not just S-Docs.