Search code examples
c#.netasp.net-mvc-4docusignapiresource-file

Docusign Email Resource File


Im trying to change the contents of the emails that DocuSign sends for various events (i.e., Completed/Voided/Declined) by customizing the "Email Resource File" in the demo sandbox account. I even created a new brand in the name of "Sending Custom" and imported a sample resource and modified the "SenderEnvelopeComplete(en)" template.. I have used the brandid in my rest api code too but it is showing me the default template all the time when i send documents..

When i use emailblurb on my code and send documents,things are working fine but i wish to change the whole email content for various events by changing things in the "Email Resource File".. Tried things seeing this "Can we customize the DocuSign response Email Blurb(Content) at runtime on each envelope?" but it didnt help me much.. It would be really helpful if someone gives me a clear shot on this.. Below is the snapshot for the things i have tried to achieve that..

Having another question to ask not sure whether this point is possible,im sending the same document to two different recipients at the same time and is that possible to send two different email contents for them respectively?

Screenshots of Branding in demo docusign sandbox account:

enter image description here

enter image description here

Code for creating documents using custom BrandId:

                    Signer signer = new Signer();

                    signer.Name = FormData.InsuredName;

                    signer.Email = FormData.InsuredEmail;
                    signer.RecipientId = "1";


                    // Create a |SignHere| tab somewhere on the document for the recipient to sign
                    signer.Tabs = new Tabs();
                    signer.Tabs.SignHereTabs = new List<SignHere>();
                    signer.Tabs.TextTabs = new List<Text>();
                    signer.Tabs.CheckboxTabs = new List<Checkbox>();
                    SignHere signHere = new SignHere();


                    for (int m = 0; m < 17; m++)
                    {
                        Text textHere = new Text();


                        if (m == 0)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Company/Insured Name";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 122).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top - 4).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 1)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Contract/Account # (if known)";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 146).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 20).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 2)
                        {

                            for (int c = 0; c < 2; c++)
                            {
                                Checkbox checkHere = new Checkbox();
                                checkHere.DocumentId = "1";
                                checkHere.PageNumber = (s + 1).ToString();
                                checkHere.RecipientId = "1";
                                if (c == 0)
                                {
                                    checkHere.TabLabel = "Credit Automatic Payments";
                                    checkHere.Required = "false";
                                    checkHere.XPosition = ((int)extractorCredit.FoundText.Left + 118).ToString();
                                    checkHere.YPosition = ((int)extractorCredit.FoundText.Top + 141).ToString();
                                }
                                else
                                {

                                    checkHere.TabLabel = "Credit Down Payments";
                                    checkHere.Required = "false";
                                    checkHere.XPosition = ((int)extractorCredit.FoundText.Left + 319).ToString();
                                    checkHere.YPosition = ((int)extractorCredit.FoundText.Top + 141).ToString();

                                }
                                signer.Tabs.CheckboxTabs.Add(checkHere);
                            }

                        }
                        if (m == 3)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Name on Card";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 82).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 170).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 4)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Credit Card";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 82).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 195).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 5)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Expiration Date";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 85).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 232).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 6)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Expiration Year";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 112).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 232).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 7)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "CVV Code";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 236).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 232).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 8)
                        {

                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Billing Address";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 82).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 257).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 9)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "City";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 82).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 282).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 10)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "State";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 226).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 282).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 11)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Zip";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 303).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 282).ToString();
                            textHere.Required = "false";
                        }

                        if (m == 12)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Name(s)";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 55).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 382).ToString();
                            textHere.Required = "false";
                        }

                        if (m == 13)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Date";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 258).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 382).ToString();
                            textHere.Required = "false";
                        }

                        if (m == 14)
                        {
                            SignHere signHereAch = new SignHere();
                            signHereAch.DocumentId = "1";
                            signHereAch.PageNumber = (s + 1).ToString();
                            signHereAch.RecipientId = "1";
                            signHereAch.TabLabel = "Signature";
                            signHereAch.XPosition = ((int)extractorCredit.FoundText.Left + 58).ToString();
                            signHereAch.YPosition = ((int)extractorCredit.FoundText.Top + 410).ToString();
                            signHereAch.ScaleValue = .6;
                            signHereAch.Optional = "true";
                            signer.Tabs.SignHereTabs.Add(signHereAch);
                        }
                        if (m == 15)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Contact Phone";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 336).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 432).ToString();
                            textHere.Required = "false";
                        }
                        if (m == 16)
                        {
                            textHere.DocumentId = "1";
                            textHere.PageNumber = (s + 1).ToString();
                            textHere.RecipientId = "1";
                            textHere.Locked = "false";
                            textHere.Font = "Arial";
                            textHere.FontSize = "4";
                            textHere.TabLabel = "Email Address";
                            textHere.XPosition = ((int)extractorCredit.FoundText.Left + 82).ToString();
                            textHere.YPosition = ((int)extractorCredit.FoundText.Top + 470).ToString();
                            textHere.Required = "false";
                        }

                        signer.Tabs.TextTabs.Add(textHere);
                    }

                    envDef.Recipients.Signers.Add(signer);


        // set envelope status to "sent" to immediately send the signature request
        envDef.EnvelopeIdStamping = "false";
        envDef.Status = "sent";
        envDef.BrandId = "31682b06-6e7a-4ab6-a13a-c9cd68253389";
        //envDef.EmailBlurb = "Hi " + FormData.InsuredName + ",Please review the ***.";


        // Use the EnvelopesApi to send the signature request!
        EnvelopesApi envelopesApi = new EnvelopesApi();


        EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef);

Solution

  • Yes, you can set which brand is used for a specific envelope. From the docs:

    Rules for determining the brandId used in an envelope

    The following rules are used to determine the brandId used in an envelope:

    If a brandId is specified in the envelope/template and that brandId is available to the account, that brand is used in the envelope.

    If more than one template is used in an envelope and more than one brandId is specified, the first brandId specified is used throughout the envelope.

    In cases where no brand is specified and the sender belongs to a Group; if there is only one brand associated with the Group, then that brand is used in the envelope. Otherwise, the account’s default signing brand is used.

    For envelopes that do not meet any of the previous rules, the account's default signing brand is used in the envelope.

    Set up the brands via the web interface. Please edit the branding file carefully! I suggest that you put your branding file under source control with frequent checkins so you can back-track when you have a problem.

    Q: Can I set a different message per recipient?

    Yes. The emailblurb field is for the common message. The emailNotification field enables you to provide recipient-specific email settings. The API field is an object with the fields:

    • emailBody: string Specifies the email body of the message sent to the recipient. Maximum length: 10000 characters.
    • emailSubject: string Specifies the subject of the email that is sent to the recipient. Merge field information can be included in the email subject.
    • supportedLanguage:string What language should be used for the DocuSign-generated parts of the email. This is used to pull the right language fields from the branding file.