Conditionally Including Content into Your GoldMine E-Mail Templates Based on the Value in a Field

The ability to conditionally include email content via text files into a GoldMine HTML e-mail template can be quite valuable when building marketing campaigns and templates to be used for mass mailings or even one-off e-mails.

The option in the GoldMine email template composition menu to include a text file is clear enough — you insert your HTML into a .TXT file and create an e-mail template in GoldMine with nothing but a reference to the .TXT file. When you merge the template, the HTML in the .TXT file will become the content of your e-mail. The option to conditionally include a .TXT file is not as clear or the uses for it may not be apparent for some.

emailconditionalyincludedFirst lets discuss some of the uses and reasons why you might want to conditionally include content into your GoldMine email templates. One good example is when you want to send your monthly newsletter with only the relevant information that your subscribers have requested. Let’s assume for instance that your business sells womens clothing. The newsletter sign-up form on your website gives the subscriber the option of selecting which products they want to receive monthly information about, for example womens accessories, dresses, t-shirts, swim wear etc etc. When the subscriber submits their information with their selection(s) it updates their record in GoldMine and populates several fields with the options they have indicated that they want to receive information about. Now when you build your monthyly newsletter you have the ability to have only the information about the products the customer has expressed interested in being sent vs bombarding them with products they are not interested in.

Another good example, is when you want to customize your email footer/signature so that the emails look like they are coming from an assigned sales rep vs the person who sent the email. This could be done by having a field in the record that is populated with the assigned sales rep name or code and then you can build your email to conditionally include a different footer/signature based on that value in the sales rep field.

Next lets discuss how you might implement an email using conditionally included text files.

In constructing your e-mail, you would want to put together the basic body of your HTML document with your logo, web-site links, signature etc. and then break the HTML code it into several different .txt files. For instance you might have a header.txt file that contains all the HTML for the header section of your email. You might also have a footer.txt file that contains your HTML code for the footer section of your email. Now if you want to have the main content of the email be conditionally included based on values in a field, then you might have several different text files that contains the HTML for the different sections of the newsletters main content.

Lets look at some sample code:

First you’ll want to start by creating a new Email Template in GoldMine. If your .txt files contain HTML code then you’ll want to make sure you’re using a Rich-Text format for your email template vs plain text. Next you’ll insert your included text files and conditionally included text files into your email template, similar to the code example below.

Use the include and  conditionally include a .TXT file options to craft a series of macros like these:

<<file:G:\goldmine\email templates\newsletter\header.txt>>
<<file:(contact2->udresses)=”Yes”?G:\goldmine\email templates\newsletter\dresses.txt>>
<<file:(contact2->utshirts)=”Yes”?G:\goldmine\email templates\newsletter\tshirts.txt>>
<<file:(contact2->ushoes)=”Yes”?G:\goldmine\email templates\newsletter\shoes.txt>>
<<file:(contact2->uaccessories)=”Yes”?G:\goldmine\email templates\newsletter\accessories.txt>>
<<file:G:\goldmine\email templates\newsletter\footer.txt>>

In the above example we have 4 fields, udresses, utshirts, ushoes, uaccessories, and when merging the email template to a contact record if the field value associated with that contact record is equal to Yes we will include the associated .txt file into the email, if the value of the field does not equal Yes then the content from the .txt file wont be included.