关于c#:DocuSign(向客户端发送电子邮件)ASP.NET MVC

DocuSign (sending email to client) ASP.NET MVC

我正在使用DocuSign演示帐户以电子邮件形式发送文档,以便使用C向客户端签名。我正在使用此链接中的代码(https://www.docusign.com/developer center/api overview quickstart)来执行此操作。但当我运行代码时,它不会向客户机发送任何电子邮件,也不会显示任何错误。我还尝试使用httpwebrequest和ajax发布认证后返回的baseurl以及信封。结果也不太好。有人能帮我吗?

使用系统;

使用system.collections.generic;

使用system.linq;

使用system.text;

使用system.threading.tasks;

使用system.io;

使用newtonsoft.json;

使用docuSign.esign.api;

使用docuSign.esign.model;

使用docuSign.esign.client;

命名空间DocuSignTest{

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
class Program
{

    static void Main(string[] args)
    {

        try
        {

            // Enter your DocuSign credentials
            string Username ="[email protected]";
            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:
{0}"
, JsonConvert.SerializeObject(envelopeSummary));



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

}


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

signer.ClientUserId ="1234";

当您指定clientuserid时,您将告诉docuSign不要向签名者发送电子邮件(因为该签名者是docuSign所指的嵌入收件人)。如果删除clientuserid,则会告诉docuSign签名者是远程收件人,因此docuSign将向该收件人发送签名邀请电子邮件。