使用C#

时间:2018-02-09 18:11:05

标签: c# docusignapi

我正在尝试使用此处找到的代码重新发送信封,但没有运气。我的代码分为两部分。这是我的ASPX页面上的代码,用于调用重新发送信封的方法:

    protected void btnResend_Click(object sender, EventArgs e)
    {
        Signer signer = new Signer();
        signer.Email = txtRecipeintEmail.Text;
        signer.Name = txtRecipientName.Text;

        Manager mgr = new Manager();
        mgr.ResendEnvelope(txtEnvelopeID.Text, signer);
    }

以下是Manager类中的代码:

    public void ResendEnvelope (string envelopeID, Signer signer)
    {
        // instantiation of recipients as per https://stackoverflow.com/questions/21565765/resend-docusign-emails
        Recipients recipients = new Recipients
        {
            Signers = new List<Signer>()
            {
                    new Signer
                    {
                        RecipientId = "1",
                        RoleName = "Prospect",
                        Email = signer.Email,
                        Name = signer.Name,
                    },
                }
        };

        string accountID = GetAccountID();
        EnvelopesApi api = new EnvelopesApi();
        EnvelopesApi.UpdateRecipientsOptions options = new EnvelopesApi.UpdateRecipientsOptions();
        options.resendEnvelope = "true";
        RecipientsUpdateSummary summary = api.UpdateRecipients(accountID, envelopeID, recipients, options);

        var responses = summary.RecipientUpdateResults.ToList<RecipientUpdateResponse>();
        var errors = responses.Select(rs => rs.ErrorDetails).ToList();
    }

我的GetAccountID功能正常 - 我用它来发送信封。 txtEnvelopeID.Text中的值是根据用于发送初始电子邮件的代码设置的。我收到了最初的电子邮件。

以下是我在错误中看到的内容:

  

?错误[0] .Message   “指定的信封更正有重复的收件人。”   ?错误[0] .ErrorCode   “CORRECTION_HAS_DUPLICATE_RECIPIENTS”

当我尝试将UpdateRecipients的第三个参数设置为null时,我得到了一个不同的错误。当我将收件人留空(api.UpdateRecipients(accountID, envelopeID, options: = options))时,我收到了错误。

所以,我想出新的想法。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

您遇到的问题是您再次创建已存在的签名者,但您不会指定相同的RecipientId,因此会出现重复错误。

而不是

RecipientId = "1"

您需要确保分配原始签名者ID,请参阅以下内容:

Signers = new List<Signer>()
{
    new Signer
    {
        RecipientId = signer.RecipientId
    },
}

为了将DocuSign电子邮件重新发送给收件人,您可以使用UpdateRecipient()方法(请参阅下面的C#示例)。这将重新触发签名电子邮件,再次发送给您在recipients参数中指定的交易收件人:

RecipientsUpdateSummary recipientsUpdateSummary = 
                envelopeApi.UpdateRecipients(
                    accountId, 
                    EnvelopeId, 
                    RecipientsToNotifyAgain, 
                    new EnvelopesApi.UpdateRecipientsOptions { resendEnvelope = "true" });

以下是official documentation陈述的内容:

enter image description here