pdfMachine merge


Purchase Download Main pdfMachine merge page

Multiple line items in an email

Consecutive rows in the data source file that have the same email address can be "bundled" together and only one email is sent per bundle.

This is often the case when producing data from database queries.

An example use is sending out invoices to clients. Lets say you have a data source file containing line items such as:

email customer invoice_id invoice_date item unit_cost quantity amt_due
wayne@acme.com Acme Corp 223 23-Jan-11 blue widget $23 4 $391
wayne@acme.com Acme Corp 223 23-Jan-11 red widget $21 2 $391
wayne@acme.com Acme Corp 223 23-Jan-11 green watzit $13 1 $391
wayne@acme.com Acme Corp 223 23-Jan-11 pink jigger $19 1 $391
wayne@acme.com Acme Corp 223 23-Jan-11 black thingy $25 9 $391
bugs@somefirm.com Big Jim's Shop 224 23-Jan-11 black thingy $25 1 $250
bugs@somefirm.com Big Jim's Shop 224 23-Jan-11 pink  thingy $25 2 $250
bugs@somefirm.com Big Jim's Shop 224 23-Jan-11 red  thingy $25 3 $250
bugs@somefirm.com Big Jim's Shop 224 23-Jan-11 blue  thingy $25 4 $250
smith@smiths.com Smiths Inc. 225 23-Jan-11 blue  thingy $25 4 $100

With bundling enabled, only 3 emails will be sent, otherwise 10 emails will be sent.

When it comes to substituting merge tags with data, tags may have a number appended to them to identify which row to use in the group of rows with the same email.
e.g.
     {{item}} - the last item in the bundle
     {{item1}} - the first item in the bundle
     {{item2}} - the second item in the bundle
     ...
     {{itemN}} - the Nth item in the bundle


Note: If there are a variable number of rows per email address in the data source file, and you want to create tables with a variable numbers of rows, we recommend using HTML templates with Liquid templating language and/or Javascript.

If you need help or more information on this feature please contact