DocuSign (向客户发送电子邮件) ASP.NET MVC



我正在使用DocuSign模拟帐户将文档作为电子邮件发送,以便使用C#签名给客户端。我正在使用此链接(https://www.docusign.com/developer-center/api-overview#quickstart(中的代码来执行此操作。但是当我运行代码时,它不会向客户端发送任何电子邮件,也不会显示任何错误。我还尝试使用HttpWebRequest和ajax发布它在身份验证后返回的baseurl以及信封。它也没有成功。谁能帮我解决这个问题?

使用系统;

使用 System.Collections.Generic;

使用System.Linq;

使用系统文本;

使用System.Threading.Tasks;

使用 System.IO;

使用Newtonsoft.Json;

使用 DocuSign.eSign.Api;

使用DocuSign.eSign.Model;

使用DocuSign.eSign.Client;

命名空间文档签名测试{

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // Enter your DocuSign credentials
            string Username = "pradeepp.wayne@gmail.com";
            string Password = "******";
            string IntegratorKey = "****************";
            // specify the document we want signed
            string SignTest1File = @"C://SamplePdfSign.pdf";
            // Enter recipient (signer) name and email address
            string recipientName = "PPradeep";
            string recipientEmail = "*****************";
            // instantiate api client with appropriate environment
            string basePath = "https://demo.docusign.net/restapi";
            // instantiate a new api client
            ApiClient apiClient = new ApiClient(basePath);
            // set client in global config so we don't need to pass it to each API object
            Configuration.Default.ApiClient = apiClient;
            string authHeader = "{"Username":"" + Username + "", "Password":"" + Password + "", "IntegratorKey":"" + IntegratorKey + ""}";
            Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
            // we will retrieve this from the login() results
            string accountId = null;
            AuthenticationApi authApi = new AuthenticationApi();
            LoginInformation loginInfo = authApi.Login();
            accountId = loginInfo.LoginAccounts[0].AccountId;
            Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson());
            // Read a file from disk to use as a document
            byte[] fileBytes = File.ReadAllBytes(SignTest1File);
            EnvelopeDefinition envDef = new EnvelopeDefinition();
            envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";
            // Add a document to the envelope
            Document doc = new Document();
            doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
            doc.Name = "TestFile.pdf";
            doc.DocumentId = "1";
            envDef.Documents = new List<Document>();
            envDef.Documents.Add(doc);
            // Add a recipient to sign the documeent
            Signer signer = new Signer();
            signer.Name = recipientName;
            signer.Email = recipientEmail;
            signer.RecipientId = "1";
            // must set |clientUserId| to embed the recipient
            signer.ClientUserId = "1234";
            // Create a |SignHere| tab somewhere on the document for the recipient to sign
            signer.Tabs = new Tabs();
            signer.Tabs.SignHereTabs = new List<SignHere>();
            SignHere signHere = new SignHere();
            signHere.DocumentId = "1";
            signHere.PageNumber = "1";
            signHere.RecipientId = "1";
            signHere.XPosition = "100";
            signHere.YPosition = "150";
            signer.Tabs.SignHereTabs.Add(signHere);
            envDef.Recipients = new Recipients();
            envDef.Recipients.Signers = new List<Signer>();
            envDef.Recipients.Signers.Add(signer);
            // set envelope status to "sent" to immediately send the signature request
            envDef.Status = "sent";
            // Use the EnvelopesApi to create and send the signature request
            EnvelopesApi envelopesApi = new EnvelopesApi();
            EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);
            Console.WriteLine("EnvelopeSummary:n{0}", JsonConvert.SerializeObject(envelopeSummary));

        } //try
        catch(Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
        Console.ReadKey();
    }
}

}

我建议您从代码中注释掉(或完全删除(这一行:

signer.ClientUserId = "1234";

当您指定客户端用户ID时,您告诉DocuSign不要向签名者发送电子邮件(因为该签名者是DocuSign所说的嵌入式收件人(。 如果您删除客户端用户ID,您将告诉DocuSign签名者是远程收件人,因此DocuSign将向该收件人发送签名邀请电子邮件。

最新更新