当前位置: 首页 > 知识库问答 >
问题:

DocuSign API模板与无模板电子邮件响应

汲睿
2023-03-14

我正在开发一个应用程序,它在iframe中使用DocuSign签名,该应用程序位于一个专有的web应用程序中。签名者可以在同一个web应用程序中访问嵌入的iframe签名视图。

public EnvelopeSummary CreateEnvelope(string filePath, string username = null, string emailSubject = null, string brandID = null,List<Models.Recipient> recipients = null)
{
    EnvelopeDefinition envelopeDef = new EnvelopeDefinition
    {
        Status = "created",
        EmailSubject = emailSubject,
        BrandId = brandID
    };

    if (recipients != null)
    {
        List<Signer> signers = recipients.Select(x => new Signer() { Email = x.Email, Name = x.UserName, ClientUserId = x.RecipientID > 50 ? x.RecipientID.ToString() : null, RecipientId = x.RouteOrder.ToString(), RoutingOrder = x.RouteOrder.ToString() }).ToList();
        envelopeDef.Recipients = new Recipients() { Signers = signers };
    }

    return Factory.GetEnvelopesApi(DocuSignConfig).CreateEnvelope(accountId: Helpers.SettingsHelper.AccountID, envelopeDefinition: envelopeDef, options: null);
}
public EnvelopeSummary CreateTemplateEnvelope(string filePath,
                                                      List<DataModels.GetRole> roles = null,
                                                      DataModels.GetTemplate template = null,
                                                      string username = null,
                                                      string emailSubject = null,
                                                      string brandID = null,
                                                      List<Models.Recipient> recipients = null)
        {
            EnvelopeDefinition envelopeDef = new EnvelopeDefinition
            {
                Status = "created",
                EmailSubject = emailSubject,
                BrandId = brandID,
                TemplateId = template.TemplateKey
            };

            if (roles != null && recipients != null)
            {
                List<Signer> signers = recipients.Select(x => new Signer() { Email = x.Email, Name = x.UserName, ClientUserId = x.RecipientID > 50 ? x.RecipientID.ToString() : null, RecipientId = x.RouteOrder.ToString(), RoutingOrder = x.RouteOrder.ToString() }).ToList();
                var templateRoles = new List<TemplateRole>();
                int counter = 0;


                foreach (Signer signr in signers)
                {
                    TemplateRole thisSigner = new TemplateRole();
                    thisSigner.Email = signers[counter].Email;
                    thisSigner.Name = signers[counter].Name;
                    thisSigner.RoleName = roles[counter].RoleName;
                    templateRoles.Add(thisSigner);
                    counter++;
                }


                envelopeDef.TemplateRoles = templateRoles;
            }

            return Factory.GetEnvelopesApi(DocuSignConfig).CreateEnvelope(accountId: Helpers.SettingsHelper.AccountID, 
                                                                          envelopeDefinition: envelopeDef, 
                                                                          options: null);
        }

编辑:已解决

正如在答案的注释中提到的,通过根据收件人的值正确设置每个模板角色的ClientUserId,这个问题得到了解决。这允许使用模板角色签名者进行嵌入签名。

共有1个答案

阎扬
2023-03-14

要使用模板,您必须首先从模板创建一个信封。模板本身无法发送,因此不能对模板本身使用嵌入式签名,只能从中创建信封。下面是七种语言的代码示例。它展示了第一部分,要从生成的信封中获得嵌入签名,可以使用以下代码示例。

下面是C#代码:

 string DoWork (string signerEmail, string signerName, string ccEmail,
    string ccName, string accessToken, string basePath,
    string accountId, string templateId)
{
    // Data for this method
    // signerEmail 
    // signerName
    // ccEmail
    // ccName
    // accessToken
    // basePath
    // accountId
    // templateId

    var config = new Configuration(new ApiClient(basePath));
    config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
    EnvelopesApi envelopesApi = new EnvelopesApi(config);
    EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName, ccEmail, ccName, templateId);
    EnvelopeSummary result = envelopesApi.CreateEnvelope(accountId, envelope);
    return result.EnvelopeId;
}
private RecipientViewRequest MakeRecipientViewRequest(string signerEmail, string signerName)
{
    // Data for this method
    // signerEmail 
    // signerName
    // dsPingUrl -- class global
    // signerClientId -- class global
    // dsReturnUrl -- class global

    RecipientViewRequest viewRequest = new RecipientViewRequest();
    // Set the url where you want the recipient to go once they are done signing
    // should typically be a callback route somewhere in your app.
    // The query parameter is included as an example of how
    // to save/recover state information during the redirect to
    // the DocuSign signing ceremony. It's usually better to use
    // the session mechanism of your web framework. Query parameters
    // can be changed/spoofed very easily.
    viewRequest.ReturnUrl = dsReturnUrl + "?state=123";

    // How has your app authenticated the user? In addition to your app's
    // authentication, you can include authenticate steps from DocuSign.
    // Eg, SMS authentication
    viewRequest.AuthenticationMethod = "none";

    // Recipient information must match embedded recipient info
    // we used to create the envelope.
    viewRequest.Email = signerEmail;
    viewRequest.UserName = signerName;
    viewRequest.ClientUserId = signerClientId;

    // DocuSign recommends that you redirect to DocuSign for the
    // Signing Ceremony. There are multiple ways to save state.
    // To maintain your application's session, use the pingUrl
    // parameter. It causes the DocuSign Signing Ceremony web page
    // (not the DocuSign server) to send pings via AJAX to your
    // app,
    viewRequest.PingFrequency = "600"; // seconds
                                       // NOTE: The pings will only be sent if the pingUrl is an https address
    viewRequest.PingUrl = dsPingUrl; // optional setting

    r

eturn viewRequest;
    }
private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName, 
            string ccEmail, string ccName, string templateId)
        {
            // Data for this method
            // signerEmail 
            // signerName
            // ccEmail
            // ccName
            // templateId

            EnvelopeDefinition env = new EnvelopeDefinition();
            env.TemplateId = templateId;

            TemplateRole signer1 = new TemplateRole();
            signer1.Email = signerEmail;
            signer1.Name =  signerName;
            signer1.RoleName = "signer";
            singer1.ClientUserId = "001";

            TemplateRole cc1 = new TemplateRole();
            cc1.Email = ccEmail;
            cc1.Name = ccName;
            cc1.RoleName = "cc";

            env.TemplateRoles = new List<TemplateRole> { signer1, cc1 };
            env.Status = "sent";
            return env;
        }
 类似资料:
  • 我有一个spring mvc应用程序,我试图将日期LocalDate呈现为字符串,对于普通视图,它可以工作,但对于电子邮件,它不工作,并抛出以下错误: 原因:org.springframework.core.convert.converterNotFoundException:找不到能够从[java.time.localdate]类型转换为[java.lang.string]类型的转换器 代码:

  • 我需要建立一个响应的电子邮件模板。我做了我的研究,并了解到媒体查询不是广泛支持电子邮件客户端。 因此,我尝试不使用媒体查询,并使用。 > 但是如果我想更改移动版本的字体大小怎么办?另外,我有一个案例,客户端希望很少的块是可见的,在移动,但不是在桌面。没有媒体查询,我如何实现这些? 另外,在我添加样式规则和媒体查询的情况下,我猜iOS支持媒体查询。但是媒体查询下的规则不会出现,但是中定义的其他规则可

  • 问题内容: 我想使用Django模板发送HTML电子邮件: 我找不到任何有关的信息,而django-mailer仅发送HTML模板,而没有动态数据。 如何使用Django的模板引擎生成电子邮件? 问题答案: 从docs,要发送HTML电子邮件,你想使用其他内容类型,如下所示: 你可能需要两个用于电子邮件的模板-一个看起来像这样的纯文本模板,存储在你的模板目录下: 还有一个HTMLy,存放在以下位置

  • 问题内容: 我们有一个需要发送各种不同类型的模板电子邮件的应用程序。当前的代码非常麻烦且不够灵活。有没有一个图书馆可以帮助您完成此类工作…我们正在寻找某种用于电子邮件的模板库。 问题答案: StringTemplate还是一个非常好的模板引擎。

  • 问题内容: 我们已经配置了Jenkins-可编辑的电子邮件通知模板,以便在每次构建后发送自定义的电子邮件。 我们做了什么 : 在下一节中的脚本中,然后在下一节中,我们添加了默认的groovy脚本(例如:groovy-html.template-复制粘贴内容)。保存。 现在在项目工作下的 “构建后” 部分下,我们选择了相同的模板 但是,当我们收到电子邮件时,电子邮件就不会替换环境变量了。 ${bui

  • 我正在研究AWS Cognito,下面是关于消息定制的两个问题。 1) 我正在使用“链接”验证类型为“电子邮件验证消息”编写AWS Cognito。我遇到了一个问题,“电子邮件消息”使其动态。 2)如何根据用户组或有条件地发送不同的“电子邮件消息”内容? 请建议。 谢啦