-2

I have a built an HTML email template for a client who needs to distribute it (the template) to around 50 customers as static files. Each customer requires some level of personalization (i.e. the logo will change, the links will be customer specific etc). I've no problem placing placeholders in the areas that are custom and I will be converting the data from the client to csv or similar format.

My question is - Can the personalization process be automated so that 50 unique HTML files get spun out using the data from the csv file? So effectively it's a mail merge but where the end product is 50 static and unique HTML files and not an email? Or should I just bite the bullet and code the 50 pages by hand?

    <csv>

            IMG,Text,UniqueURL
            Customer1Logo,Customer1Text,URL1
            Customer2Logo,Customer2Text,URL2
            Customer3Logo,Customer3Text,URL3<csv>

    <body>
    <table class="body">
      <tr>
        <td class="center" align="center" valign="top">
          <center>

            <img src="DataFromTableColumn1">
            <p>DataFromTableColumn2</p>
<a href="http://www.genericlink.com.au/DataFromTableColumn3">Link to Company</a>
          </center>
        </td>
      </tr>
    </table>
  </body>
pausehere
  • 1
  • 1

1 Answers1

0

You can use any kind of programming or scripting language for that. It's just a combination of loop and string replacements:

  • In your template, define a placeholder for the values that you want to have replaced from the CSV
  • Loop over the CSV and ...

    • load the template
    • replace the templates with the corresponding column from the CSV line
    • save the template as the customized version (e.g. using the customer name/ID as part of the file name.

$path = "D:\myData.csv";

Import-Csv $path | Foreach-Object { 

    # TODO: load template

    foreach ($property in $_.PSObject.Properties)
    {
        # TODO: replace template strings using $property.Value
    } 

}
Daniel Lemke
  • 1,966
  • 18
  • 24
  • Thanks - I'll see what I can do although not being a programmer might be a stumbling block. – pausehere Aug 05 '15 at 13:47
  • It's a programmer page, so you should try to pick up a language ;-) Assuming that you're coming from a Windows background, you could easily do that with PowerShell for example. See the updated answer as a starting point, for the ToDo's, Google will be your friend ;-) – Daniel Lemke Aug 05 '15 at 13:57
  • Ha Ha careful FED's have feelings too and to be honest I've never really needed an in depth knowledge of a language thus far. Except in this case obviously. I did try the google thing but probably be quicker to do it by hand now. And thanks for the updated answer...will give it a crack. – pausehere Aug 05 '15 at 14:05