How to conditionally attach PDF files in a mail merge

pdfMachine merge allows you to specify the conditions under which you want a particular PDF attachment to be sent with the email. This effectively allows you to have varying number of attachment per email in a particular merge run. It also acts as a way to specify the template you want to use based on merge fields in the data source.

Enabled

The PDF attachment is always sent.


Enabled on condition

The PDF attachment is sent if the condition is satisfied. You can use merge fields from the data source to enter a condition. If the value in the particular row causes the condition to be met then the PDF attachment is sent for that email.

Boolean logic can be used with merge fields to set the conditions.


This can be used to attach different numbers of attachments to each email during the merge.

For example :

age >= 18

will only attach the PDF to the email if the value in the column age for that particular row is a number greater than or equal to 18.


Note : some rows to emails methods involve multiple rows of the data source per email. Only the data in the last of these consecutive rows can be used to evaluate the condition. Any conditional fields must vary based on the columns in that first row.


Conditional attachments can be used to refer to a different template based on the values in the merge fields of the data source.

 A short video tutorial is available. Watch here.

For example :

campus == 'online'

campus == 'Hawthorn'

will use a particular template if the row has a value of online for the campus. It will use a different template if the row has a value of Hawthorn for the campus. More attachments can be attached if there are more values of 'campus' that require different attachments.


Disabled : The PDF attachment is never sent. You can use this to temporarily turn off the attachment. Use the delete icon to delete the attachment if you want to permanently remove it.