pdfMachine merge - Rows To Emails Methods
pdfMachine merge is highly configurable, allowing the rows in the data source to represent emails, pages in an attachment, attachments in an email or line items in an attachment.
Each pdfMachine merge profile has a "Rows to Email" method that configures the relationship between the rows from the data source and the emails/attachments. The data from each row can be used to create PDF attachments from a Word, Excel, PowerPoint or HTML template. These are referred to as dynamic attachments because they are dynamically generated during the merge by merging the template and the data source.
Each row creates an email
This is the default method. It is the simplest and most commonly used. Use this method unless you specifically need one of the others.
One email will be sent per row in the data.
The "Each row creates an email" method means that every row in the data source will be used to generate a new email. The data from the row can be used to personalize the email details - recipients, subject, attachment name, body. Each dynamic attachment in the profile will be created as a PDF attachment for the email using data from that row.
Each row creates an attachment
This method is used when you want to send an email with multiple PDF attachments that have a similar look but different data in each attachment.
One email will be sent per group of rows in the data source.
The "Each row creates an attachment" method means that consecutive rows in the data source which have the same email address will be used to generate an email. The data from the last row in the group can be used to personalize the email details - recipients, subject, attachment name, body. Each row will cause each of the dynamic attachments in the profile to be created as a PDF. The attachment will have the merge fields replaced with data from the corresponding row of the data source. Those attachments will be sent together in a single email.
e.g. A student has completed 3 courses. One email with 3 attached certificates - with the course information of each on it - is required. The data source file has 3 rows which all have the same email address, but also has other fields which are course specific. In this case, 3 attachments will be generated and sent in a single email.
Each row appends to the PDF attachment
This method is used when you want to send an email with one PDF that has multiple pages which have a similar look but different data in each page.
One email will be sent per group of rows in the data source.
The "Each row appends to the PDF attachment" method means that consecutive rows in the data source with the same email address will be used to generate a new email. The data from the last row can be used to personalize the email details - recipients, subject, attachment name, body. Each row will cause a page to be generated for each of the dynamic attachments in the profile, merging the template with the data from that row. The pages are appended together to create a PDF which is attached to an email One mail is sent for that group of rows.
e.g. A student has completed 3 courses. One email with an attachment that has all 3 certificates combined as a single PDF is required. The data source file has 3 rows which all have the same email address, but also has other fields which are course specific. In this case, 1 attachment will be generated and sent in a single email.
One or more rows generates an email
This method is used when you want to send an email with a PDF that has repeating line items that are generated from different rows of the data source. For example invoices and statements.
One email will be sent per group of rows in the data source.
The "One or more rows generates an email" method means that consecutive rows in the data source with the same email address will be used to generate a new email. The data from the last row can be used to personalize the email details - recipients, subject, attachment name. pdfMachine merge syntax is used to designate where line items appear within the dynamic attachment and the body of the email. Each row will cause a line item to be generated where designated, merging the template with the data from that row. The resulting dynamic attachment is attached to the email. One mail is sent for that group of rows.
Note: If you want to have a variable number of rows per email address in the data source file, we recommend using HTML templates with Liquid templating language and/or Javascript.
e.g An invoice or statement. The data source file has many rows which all have the same email address, but have other fields which are line item specific. In this case, a single attachment will be generated and sent in an email.