2

I'm trying to use code I found here to resend an envelope, but no luck. My code is in two parts. Here's the code on my ASPX page to call a method to resend the envelope:

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

Here's the code in the Manager class:

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

My GetAccountID function works fine - I use it to send the envelope. The value in txtEnvelopeID.Text is set from the code used to send the initial email. I get the initial email.

Here's what I see in errors:

?errors[0].Message "The specified envelope corrections have duplicate recipients." ?errors[0].ErrorCode "CORRECTION_HAS_DUPLICATE_RECIPIENTS"

When I tried to set the third argument of UpdateRecipients to null, I got a different error. When I left recipients blank (api.UpdateRecipients(accountID, envelopeID, options: = options)), I got an error.

So, I'm out of new ideas to try. Can anyone help?

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Awerber
  • 57
  • 7

1 Answers1

2

The issue you are encountering is that you are creating again a signer that already exists, except that you don't assign the same RecipientId, hence the duplicate error.

Instead of

RecipientId = "1"

You need to make sure you assign the original signer ID, see below :

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

In order to re-send the DocuSign email to your recipients, you can use the UpdateRecipient() method as such (see my C# example below). This will re-trigger the signing email to be sent one more time to the transaction recipients you specify in the recipients parameter :

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

Here is what the official documentation states :

enter image description here

Frederic
  • 2,015
  • 4
  • 20
  • 37
  • I changed the recipient ID to a GUID (RecipientId = Guid.NewGuid().ToString()). And still get the same error. I see that your line of code uses an envelope object. Am I supposed to get an envelope object from the existing envelope? If so, how do I get the envelope object? Do you have the code that precedes that line? – Awerber Feb 09 '18 at 19:20
  • Wait... are you trying to resend an email to an existing signer or a new signer ?? I'd assume that you want to resend to an existing signer. In this case, you need to pass the same Id as the original Signer. And that's why you get a duplicate error. Any possibility to have access to the original signer object ? – Frederic Feb 09 '18 at 20:53
  • Thank you for following up. I DO want to send the email to the original signer. Please clarify your answer on exactly how to do that. I cannot tell whether I'm supposed to use the original recipient ID. I do have access to that value, as I record it in a database when the envelope is create. – Awerber Feb 09 '18 at 22:26
  • @Awerber Correct, you ARE supposed to reuse the recipient's original Id as otherwise DocuSign will think that you're trying to create another one. See my updated answer – Frederic Feb 09 '18 at 22:32
  • Thanks, re-using the ID worked. One surprise, the errors object in the summary is still given a value, but the value is SUCCESS. I will give it a spn later, but do you happen to know if I need to reuse the same name and email? I'll probably re-use those anyway. – Awerber Feb 10 '18 at 00:24
  • @Awerber Yes, it confuses me as well. Having an error message with "Success" in it is not very intuitive right ? It seems normal though... You don't need to reuse the name, email or roleName, I have just tested and the RecipientId will suffice. I have update my answer – Frederic Feb 10 '18 at 01:12