对于电子邮件模板中的循环

时间:2017-10-16 20:58:03

标签: 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>",
  }
}

1 个答案:

答案 0 :(得分:0)

是的!

示例模板数据:

using LibA;
using ProtoBuf;

[ProtoContract]
public abstract class Instrument
{
    public event EventHandler<EventArgs<Instrument>> InstrumentUpdatedEvent;
    public event EventHandler<EventArgs<decimal>> SettlementPriceUpdatedEvent;
    public event EventHandler<EventArgs<decimal>> PreliminarySettlementPriceUpdateEvent;

    [ProtoMember(1)]
    public string Id { get; private set; }
    [ProtoMember(2)]
    public ulong ProviderInstrumentId { get; protected set; }
    [ProtoMember(3)]
    public string ProviderInstrumentId2 { get; protected set; }
}

public class ProviderInstrument : Instrument
{
    private static readonly ILog Log = LogManager.Create();
    private ProviderInstrument()
    {

    }

    public ProviderInstrument(ContractType contractType)
    {
        ContractType = contractType;
    }

    public override void Update()
    {
        // Base class fields set here
    }
}

示例模板:

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

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