简体   繁体   English

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

[英]DocuSign (sending email to client) ASP.NET MVC

I am using DocuSign demo account to send a document as an email for signing to the client using C#. 我正在使用DocuSign模拟帐户将文档作为电子邮件发送,以使用C#签名给客户端。 I am using the code in this link ( https://www.docusign.com/developer-center/api-overview#quickstart ) to do that. 我正在使用此链接( https://www.docusign.com/developer-center/api-overview#quickstart )中的代码来执行此操作。 But when I run the code it is not sending any email to the client and it is not showing any error too. 但是,当我运行代码时,它不会向客户端发送任何电子邮件,也不会显示任何错误。 I also tried posting the baseurl that it returns after authentication along with the envelope using HttpWebRequest and also with ajax. 我还尝试过将通过身份验证后返回的baseurl与使用HttpWebRequest以及ajax的信封一起发布。 It didn't worked out too. 它也没有解决。 Can anyone please help me with this ? 有人可以帮我吗?

using System; 使用系统;

using System.Collections.Generic; 使用System.Collections.Generic;

using System.Linq; 使用System.Linq;

using System.Text; 使用System.Text;

using System.Threading.Tasks; 使用System.Threading.Tasks;

using System.IO; 使用System.IO;

using Newtonsoft.Json; 使用Newtonsoft.Json;

using DocuSign.eSign.Api; 使用DocuSign.eSign.Api;

using DocuSign.eSign.Model; 使用DocuSign.eSign.Model;

using DocuSign.eSign.Client; 使用DocuSign.eSign.Client;

namespace DocuSignTest { 命名空间DocuSignTest {

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();
    }
}

} }

I'd suggest that you comment-out (or remove altogether) this line from your code: 我建议您从代码中注释掉(或完全删除)这一行:

signer.ClientUserId = "1234";

When you specify ClientUserId , you're telling DocuSign not to send an email to the signer (because that signer is what DocuSign refers to as an embedded recipient). 当您指定ClientUserId时 ,您是在告诉DocuSign不要向签名者发送电子邮件(因为该签名者是DocuSign所指的嵌入式收件人)。 If you remove ClientUserId , you're telling DocuSign that the signer is a remote recipient, so DocuSign will send a signing invitation email to that recipient. 如果删除ClientUserId ,则告诉DocuSign签名者是远程收件人,因此DocuSign将向该收件人发送签名邀请电子邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM