【问题标题】:For loop in email template电子邮件模板中的 For 循环
【发布时间】:2020-01-17 05:26:49
【问题描述】:

我们可以为 SES 模板创建一个 for 循环吗?

查看此处的代码 (https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-personalized-email-api.html),我看到的唯一示例是键值对。

语法看起来像我以前在handlebar.js 中使用的。

类似这样的:

{
  "Template": {
    "TemplateName": "MyTemplate",
    "SubjectPart": "Greetings, {{name}}!",
    "HtmlPart": "<h1>Hello {{name}},</h1><p>Your favorite animals are {{#each animals}}<h1>{{favoriteanimal}}</h1>{{/each}}.</p>",
  }
}

【问题讨论】:

    标签: amazon-web-services amazon-ses


    【解决方案1】:

    是的!

    示例模板数据:

    {
      "meta":{
        "userId":"51806220607"
      },
      "contact":{
        "firstName":"Anaya",
        "lastName":"Iyengar",
        "city":"Bengaluru",
        "country":"India",
        "postalCode":"560052"
      },
      "subscription":[
        {
          "interest":"Sports"
        },
        {
          "interest":"Travel"
        },
        {
          "interest":"Cooking"
        }
      ]
    }
    

    示例模板:

    {
      "Template": {
        "TemplateName": "Preferences",
        "SubjectPart": "Subscription Preferences for {{contact.firstName}} {{contact.lastName}}",
        "HtmlPart": "<h1>Your Preferences</h1>
                     <p>You have indicated that you are interested in receiving 
                       information about the following subjects:</p>
                     <ul>
                       {{#each subscription}}
                         <li>{{interest}}</li>
                       {{/each}}
                     </ul>
                     <p>You can change these settings at any time by visiting 
                        the <a href=https://www.example.com/prefererences/i.aspx?id={{meta.userId}}>
                        Preference Center</a>.</p>",
        "TextPart": "Your Preferences\n\nYou have indicated that you are interested in 
                     receiving information about the following subjects:\n
                     {{#each subscription}}
                       - {{interest}}\n
                     {{/each}}
                     \nYou can change these settings at any time by 
                     visiting the Preference Center at 
                     https://www.example.com/prefererences/i.aspx?id={{meta.userId}}"
      }
    }
    

    更多信息可以在这里找到:https://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-personalized-email-advanced.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-31
      • 2019-08-03
      • 1970-01-01
      • 2016-08-13
      • 1970-01-01
      • 1970-01-01
      • 2014-06-08
      • 1970-01-01
      相关资源
      最近更新 更多