amazon-web-services - 电子邮件模板中的 For 循环

标签 amazon-web-services amazon-ses

我们可以为 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>",
  }
}

最佳答案

是的!

示例模板数据:

{
  "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

关于amazon-web-services - 电子邮件模板中的 For 循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46779000/

相关文章:

java - 通过命令行上传 Java Elastic Beanstalk 应用程序

java - Amazon Forecast 查询 Java 集成

amazon-web-services - AWS CodePipeline 自定义 Lambda 函数永远运行且永不返回

amazon-web-services - 如何使用 CDK 生成 AWS SES SMTP 凭证?

email - 无法让 Zabbix 发送电子邮件警报

sql-server - SQL Server 2012 CPU 使用率飙升至 100%

amazon-web-services - 为 aws cognito id token 生成基于角色的声明

perl - Net::SMTP::SSL(通过 gmail 和 amazon smtp)- 发送带附件的电子邮件时为 'Connection Closed'

heroku - 在 Heroku 上运行时,如何配置 Meteor 以使用 Amazon SES?

email - 如何配置 GlassFish JavaMail 以使用 Amazon SES?