Each envelope type will have its own email subject/body that is static for that envelope type. Here is an example of a few predetermined envelope types:
- Mortgage closing documents
- Mortgage loan application documents
These envelopes will contain a varied number of documents and each document is unique. I've attempted to create a template without a document, but it appears that is not allowed.
I'd like to be able to save the email body and subject for these envelope types so that when I send an envelope via the DocuSign API, I don't have to directly specify these fields. I'm hoping to avoid storing the subject/body inside of code or a configuration file. Preferably, I'd like a non-technical person to be able to change the subject/body through the DocuSign interface.
What I ended up doing:
Based on Kim Brandl's recommendations, I wrote the following code which worked as expected. A few notes:
- The initial file that you added to the template will not appear in the final envelope if the ServerTemplate sequence is greater than the InlineTemplate. You can read more here.
The Recipients, signers, documents, etc., follow the same pattern as a standard EnvelopeDefinition except the data is placed under the InlineTemplate.
string docBase64 = Convert.ToBase64String(file.Stream.ReadAsBytes()); EnvelopeDefinition envDef = New EnvelopeDefinition(); envDef.Status = "created"; // The first sequence that appears will be the first document that is applied. // If you want the uploaded documents to appear instead of the server template, // make the server template a higher number. envDef.CompositeTemplates = new List<CompositeTemplate> { new CompositeTemplate() { ServerTemplates = new List<ServerTemplate>() { new ServerTemplate("2", templateId) }, InlineTemplates = new List<InlineTemplate>() { new InlineTemplate() { Sequence = "1", Recipients = new Recipients() { Signers = new List<Signer>() { new Signer() { Email = request.Recipients[0].UserEmail, Name = request.Recipients[0].UserName, RoleName = request.Recipients[0].RoleName, RecipientId = (1).ToString() } } }, Documents = new List<Document>() { new Document() { DocumentBase64 = docBase64, DocumentId = "3", Name = "ConsentFake.pdf", IncludeInDownload = "true" }, new Document { DocumentBase64 = docBase64, DocumentId = "9", Name = "ConsentFake2.pdf", IncludeInDownload = "true" } } } } } };
Summary: This allowed me to take advantage of a DocuSign template's email subject/body without having to use a specific template document.