Submit - C#

Copy
// DocumentNOW V2 Submit example

// force TLS 1.2 if .net < 4.6
ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
    
Guid accountContextID = new Guid(<fromYourAccount>);
Guid templateID = new Guid(<yourTemplateId>);
    
// assuming we set the namespace on the service proxy to DocNow ...
// there are multiple bindings for submit, so pass in whichever you want to use
DocNow.SubmitServiceClient submitter = new DocNow.SubmitServiceClient("BasicHttpBinding_ISubmitService");

DocNow.Document doc = new DocNow.Document();
doc.ContextIdentifier = accountContextID;
doc.Template = new DocNow.Template();
doc.Template.Id = new templateID;
doc.Metadata = new DocNow.Metadata();
doc.Metadata.UserName = "me@mydomain.com";
doc.Metadata.DocumentName = "testing" + DateTime.Today.Ticks.ToString();
doc.Metadata.ExpirationDate = DateTime.Today.AddDays(5);
doc.Metadata.Password = "578jNhj$5"; // this would be a completed document password, not a password for a signer
doc.Metadata.OrderNumber = "6657822778"; // some extra data you would like to pass to link back to your system

// if this document exists in an envelope created by CreatEnvelope, pass an EnvelopeId
// doc.Metadata.EnvelopeId = envelopeID;

// template parameters will be relative to the template you are using, this is just an example 
doc.Template.Parameters = new DocNow.Parameter[4]; 
doc.Template.Parameters[0] = new DocNow.Parameter(); 
doc.Template.Parameters[1] = new DocNow.Parameter(); 
doc.Template.Parameters[2] = new DocNow.Parameter(); 
doc.Template.Parameters[3] = new DocNow.Parameter(); 
doc.Template.Parameters[0].Name = "Signatory 1 Email Address"; 
doc.Template.Parameters[0].Value = "mysigner@mydomain.com"; 
doc.Template.Parameters[1].Name = "Signatory 1 First Name"; 
doc.Template.Parameters[1].Value = "John"; 
doc.Template.Parameters[2].Name = "Signatory 1 Last Name"; 
doc.Template.Parameters[2].Value = "Doe"; 
doc.Template.Parameters[3].Name = "Passed in data"; 
doc.Template.Parameters[3].Value = "xxxxxxxxxxxxxxx"; 
DocNow.DocumentResult[] results = submitter.Submit(new DocNow.Document[] { doc }); 
if (results.Length > 0) 

    if (results[0].Exceptions != null) 
    { 
        StringBuilder sb = new StringBuilder(); 
        foreach (DocNow.DocumentException exception in results[0].Exceptions) 
        { 
            sb.AppendFormat("{0} : {1}{2}", exception.Severity.ToString(), exception.Value, Environment.NewLine); 
        } 
        Console.WriteLine(sb.ToString()); 
    } 
    else 
    { 
        // documentID will be results[0].Id; 
        // authtoken for the document will be results[0].AuthToken; 
    }