Introduction

This article describes how to use the HTML held in a database in your Format as HTML ProClosed The Format as HTML Pro tool is used to create a task step that produces single or multiple HTML documents. You can choose to create the HTML template from scratch or import a pre-existing template. Recordsets and other task step properties can also be used to populate the HTML document to product dynamic content documents. These documents can then be consumed and then delivered by Output or Execute task steps. template.

Scenario

Because of the flexible nature of BPA Platform, we will use the example of creating an HTML email template to demonstrate how to use HTML stored in a database. This HTML contains an email footer for all emails sent.

Required Tools

Database Query (ODBC)Closed You typically use the Database Query (ODBC) tool to extract specific records from a relational database, using a valid ODBC driver to make the connection. These are then made available to other task steps as a recordset. or Database Query (OLEDB)Closed You typically use the Database Query (OLEDB) tool to extract specific records from a relational database, using a valid ODBC driver to make the connection. These are then made available to other task steps as a recordset.
Format as HTML Pro
Send Email (SMTP)Closed The Send Email (SMTP) tool sends messages to any SMTP compliant mail server. This tool is capable of sending multiple messages in either text or HTML formats, incorporating data from Input and Format steps to any number of recipients. If recordset data being used from an Input step includes a column containing email addresses, then this can be used as a "dynamic" recipient address.

The following procedure assumes the following:

You have created a global connection to the relevant database using either Database Query tool
You have created a global connection to the relevant SMTP server to send the emails

Creating the Task

This procedure focuses on the configuration required to use HTML from a database when creating templates in the Format as HTML Pro tool.

The Format as HTML Pro Step

To use HTML stored in a database in your Format as HTML Pro template, do the following:

  1. Create a new task.
  2. Add a Database Query step to retrieve the data to populate your template.
  3. Add a Database Query step to retrieve the fields containing the HTML — even when your HTML fields are in the same database as the template data, you should separate this out into a different recordset.
  4. Add a Format as HTML Pro step and configure the HTML template as required by your task.
  5. Still in the Format as HTML Pro step, go back to the Data tab.
  6. From the Input Recordsets pane, drag the recordset containing the HTML fields to the Structure pane so it becomes a child node to Document:

Format as HTML Pro - Data Tab - HTML Injection

  1. Go to the Design tab.
  2. In the Structure pane, select the new HTML results node.
  3. In the Fields pane, select the field that contains the required HTML.
  4. From the Field Properties pane, expand Format and set Raw to True.

    This forces the Format as HTML Pro tool to treat anything in this field as raw HTML rather than as plain text (default), that is, render <strong>Hello World</strong> as Hello World in the eventual output, rather than outputted exactly as seen in the recordset.

    Format as HTML Pro - Design Tab - Field Properties

  5. In the HTML design area, add the following HTML to the relevant location in the HTML template:

    <div class="-bpa-fah-row-"></div>

    For this exercise, we're adding it to the bottom of the template as this is the email footer.

  6. From the Structure pane, drag the new HTML results node to the HTML design area and drop it between row- and the closing "> in the opening div element.
  7. Select Node ID from the resultant pop-up menu.
  8. From the Fields pane, drag the field containing the HTML to the HTML design area and drop it between the opening and closing div elements.

    Your HTML document should look like this now:

    Format as HTML Pro - Design Tab - Injected HTML

    This div is just a container for the HTML extracted from the database; it plays no part in the formatting of the HTML. The BPA Platform-specific class indicates which recordset the field belongs to. For more information about available BPA Platform-specific classes, see A Note About the BPA Platform-Specific HTML Classes.

  9. Click OK to save and close this step.
  10. Add a Send Email (SMTP) step to the task which consumes the Format as HTML Pro step and uses this as the Document Output.
  11. Connect your steps so the task looks like:

Format as HTML Pro - Inject HTML Task

Now when the task is run, the HTML is added as a static element to the end of the HTML email sent.

For the purposes of this exercise, we have used a single HTML field; you can expand this to include as many fields as required.