Search code examples
c#sparkpost

Cannot put customer data in sparkpost email


I'm attempting to create a Sparkpost email where the template generates to say the recipient's name like "Hello, David" for example. For reference I'm making a call from a web app that uses C#. The sparkpost website doesn't seem to have any information on doing things like this. Can someone give me some pointers please?


Solution

  • To do that you would put something like this in your template:

    Hello, {{address.name}}
    

    Then in your recipient's array do something like this

        "recipients": [
        {
          "address": {
            "email": "[email protected]",
            "name": "David"
          }
                  :
                  :
      ] 
    

    Here is an article I wrote a while back that may help:

    https://www.sparkpost.com/blog/advanced-email-templates/

    I also have various Template example here written in Java incase it can help:

    https://github.com/SparkPost/java-sparkpost/tree/master/apps/sparkpost-samples-app/src/main/java/com/sparkpost/samples