我正在使用DocuSign模拟账户将文档作为电子邮件发送,以便使用C#签署给客户。我正在使用此链接中的代码(https://www.docusign.com/developer-center/api-overview#quickstart)来执行此操作。但是当我运行代码时,它没有向客户端发送任何电子邮件,也没有显示任何错误。我还尝试使用HttpWebRequest和ajax发布它在认证后返回的baseurl以及信封。它也没有成功。有人可以帮我这个吗?
使用System;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Threading.Tasks;
使用System.IO;
使用Newtonsoft.Json;
使用DocuSign.eSign.Api;
使用DocuSign.eSign.Model;
使用DocuSign.eSign.Client;
命名空间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();
}
}
}
答案 0 :(得分:0)
我建议你从代码中注释掉(或完全删除)这一行:
signer.ClientUserId = "1234";
当您指定 ClientUserId 时,您告诉DocuSign不要向签名者发送电子邮件(因为该签名者是DocuSign所称的嵌入式收件人)。如果您删除 ClientUserId ,则表示签名者是远程收件人,因此您将告知DocuSign,因此DocuSign将向该收件人发送签名邀请电子邮件。