// Configure the envelope information
DocuSignWeb.EnvelopeInformation envelopeInfo = new DocuSignWeb.EnvelopeInformation();
envelopeInfo.AccountId = _accountId;
envelopeInfo.EmailBlurb = "testing docusign creation services";
envelopeInfo.Subject = "create envelope from templates and forms test";
DocuSignWeb.CompositeTemplate template = new DocuSignWeb.CompositeTemplate();
DocuSignWeb.Recipient recipient1 = new DocuSignWeb.Recipient();
recipient1.UserName = "SignerOne";
// TODO: replace the email string with an actual email
recipient1.Email = "test email one";
recipient1.Type = DocuSignWeb.RecipientTypeCode.Signer;
recipient1.RequireIDLookup = false;
recipient1.RequireIDLookupSpecified = true;
recipient1.RoutingOrder = 1;
recipient1.RoutingOrderSpecified = true;
recipient1.RoleName = "One";
recipient1.ID = "1";
DocuSignWeb.Recipient recipient2 = new DocuSignWeb.Recipient();
recipient2.UserName = "Signer2";
// TODO: replace the email string with an actual email
recipient2.Email = "test email two";
recipient2.Type = DocuSignWeb.RecipientTypeCode.Signer;
recipient2.RequireIDLookup = false;
recipient2.RequireIDLookupSpecified = true;
recipient2.RoutingOrder = 2;
recipient2.RoutingOrderSpecified = true;
recipient2.RoleName = "Two";
recipient2.ID = "2";
DocuSignWeb.Recipient[] signers = { recipient1, recipient2 };
// Configure the inline templates
DocuSignWeb.InlineTemplate inlineTemplate = new DocuSignWeb.InlineTemplate();
inlineTemplate.Sequence = "1";
inlineTemplate.Envelope = new DocuSignWeb.Envelope();
inlineTemplate.Envelope.Recipients = signers;
inlineTemplate.Envelope.AccountId = _accountId;
// This tab matches the DateSigned tab assigned to recipient one
DocuSignWeb.Tab tab1 = new DocuSignWeb.Tab();
tab1.RecipientID = "1";
tab1.TabLabel = "DocuSignDateSignedOne";
tab1.Type = DocuSignWeb.TabTypeCode.DateSigned;
// This tab matches the SignHere tabs assigned to recipient two
DocuSignWeb.Tab tab2 = new DocuSignWeb.Tab();
tab2.RecipientID = "2";
tab2.TabLabel = "SignTwo\\*";
tab2.Type = DocuSignWeb.TabTypeCode.SignHere;
// This tab matches the SignHere tabs assigned to recipient one
DocuSignWeb.Tab tab3 = new DocuSignWeb.Tab();
tab3.RecipientID = "1";
tab3.TabLabel = "SignOne\\*";
tab3.Type = DocuSignWeb.TabTypeCode.SignHere;
// This tab matches the DateSigned tab assigned to recipient two
DocuSignWeb.Tab tab4 = new DocuSignWeb.Tab();
tab4.RecipientID = "2";
tab4.TabLabel = "DocuSignDateSignedTwo";
tab4.Type = DocuSignWeb.TabTypeCode.DateSigned;
// This tab matches nothing -- but that's okay!
// It will just get discarded
DocuSignWeb.Tab tab5 = new DocuSignWeb.Tab();
tab5.RecipientID = "1";
tab5.TabLabel = "asdf";
tab5.Type = DocuSignWeb.TabTypeCode.FullName;
inlineTemplate.Envelope.Tabs = new DocuSignWeb.Tab[] { tab1, tab2, tab3, tab4, tab5 };
template.InlineTemplates = new DocuSignWeb.InlineTemplate[] { inlineTemplate };
// Configure the document
template.Document = new DocuSignWeb.Document();
template.Document.ID = "1";
template.Document.Name = "Form Document";
template.Document.PDFBytes = <Test Document>;
template.Document.TransformPdfFields = true;
template.Document.FileExtension = "pdf";
// Create draft with all the composite template information
DocuSignWeb.EnvelopeStatus status =
_apiClient.CreateEnvelopeFromTemplatesAndForms(envelopeInfo,
new DocuSignWeb.CompositeTemplate[] { template }, false);