Using Mail Merge Tags

 

What are Mail Merge Tags?

Mail merge tags allow you to insert information from your database directly into your email messages. You can use mail merge tags to personalize your messages for each user. Basic example include (with personalized text in bold):

 

 Dear Joe:

 

 Wouldn't your dog Rex like to...?

 

 We see that you have an account balance of $34.05.

 

The easiest way to personalize your message is to use the Insert Field wizard when creating content. This section discusses how to manually insert these tags if you don't want to use the wizards, or if you'd like to do more advanced personalization and scripting.

 

What are some of the merge tags I can use right now?

ListManager includes a large number of short and long tags with the product that you can use immediately. To learn more, see the section Mail Merge Short Tags.

 

How can I have ListManager generate these tags for me automatically?

If you create content, you can use the Insert Field feature to automatically merge in mail merge tags for you.

 

How do I manually create a Mail Merge Tag?

ListManager supports two different types of mail merge tags: short tags, and long tags.

 

Short tags are created automatically by ListManager for all fields in your members data table. The short tag syntax is simple:

 

%%fieldname%%

 

where fieldname refers to a field in your member table. Short tags are case sensitive, and only work for fields in your members table. If there's no information available, it will be left blank.

 

For example, to merge in a member's full name using the short tag, you would put the following in your message:

 

Dear %%FullName_%%

 

When Thomas Middleton receives the message, he'll see:

 

Dear Thomas Middleton,

 

Because merging from the members table is so common, ListManager lets you merge in information from this table using this simpler short tag format. Short tags are limited to your members table; to merge in other information, use long tags. See Mail Merge Short Tags for a list of tags.

 

Long tags let you insert fields from any database table to which ListManager has access. The long tag syntax is:

 

%%merge tablename.fieldname%%

 

where fieldname refers to a field (or column) in the database table tablename. Note that, like short tags, regular tags are case sensitive.

 

To merge in a recipient's full name using a long tag, you would include the following in your message:

 

Dear %%merge members_.FullName_%%

 

In this case, we chose a field from the members_ table to merge into our message. Any field from the members_ table can be inserted in this manner.

 

You can also merge data from other tables as well if you send your message to a subset which includes a join to another table (ListManager Pro or Enterprise only). For example, suppose you created a subset which joined to a table called demographics which had a field called phonenumber. You could insert this data into your message by using the following mail merge tag:

 

Our records show we can contact you at %%merge demographics.phonenumber%%

 

Generally, data from the lists_, topics_, sites_, inmail_ and outmail_ tables are already associated with the message, so you can merge in information from these tables without creating a subset with a jointo these tables. If you sent your message to a subset, you can also merge data from the subsets_ table.

 

How do I use the Mail Merge Tags?

To use mail merge tags, simply insert the tag where you want the text to be placed. ListManager will automatically replace the tag with the appropriate data.

 

Let's say you have a field in your member table called FirstName. Because the field is in your member table, ListManager automatically created a short tag for it, in the format To use it, here is what you would write:

Dear %%FullName_%%,

Let me tell you about this great opportunity...

 

When you send the message, ListManager will remove the tag and replace it with the value stored in the FullName_ field. Bob Jones, for example, would receive an email beginning this way:

 

Dear Bob Jones,

Let me tell you about this great opportunity...

 

And Mary Wong would see:

 

Dear Mary Wong,

Let me tell you about this great opportunity...

 

Long tags work exactly the same. Let's say you're writing to a group of pet owners. Bob has a dog named Fluffy, and you store information about Bob's dog in your pets database table. The petstable includes two fields, PetType and PetName. Since these fields are not part of the Member_ table, you must send to a subset which joins your pets table, and then specify them using the long tags. Simply type:

 

Dear %%FullName%%,

Wouldn't your %%merge pets.PetType%% %%merge pets.PetName%% love a new, warm blanket during these winter months?

 

As with the short tags, ListManager will replace the tag with the information stored in your tables. Bob, for example, would see:

 

Dear Bob Jones,

Wouldn't your dog Rex love a new, warm blanket during these winter months?

 

And Mary, who owns a cat, would see:

 

Dear Mary Wong,

Wouldn't your cat Snookums love a new, warm blanket during these winter months?

 

Where can I use the tags?

You can use most tags in all parts of your message including the body, subject, header, footer, to: fields, and from: fields. The merge tags can also be used in documents (hello, goodbye, etc.).

 

Some tags such as %%merge whatlists%% return a list of values, which would not be displayed properly in one line fields (e.g., the Subject).

 

What if a field is blank?

If a field is blank, the merge tag will simply be removed and be replaced by nothing in most cases. If this is a problem, you should consider using a Conditional Content Command, which can easily provide a default value in case a field is empty. (Note that some of the Mail Merge Short Tags also do this in a few simple cases.)

 

What if I want recipients to see the word "%%anything%%" in my message?

To keep ListManager from replacing a piece of text that looks like a merge tag, just place a blackslash ("\") in front of the script delimiters (the double %% sign), like so:

 

Dear %%firstname%%,

Using merge tags in the To: field is easy! Just type \%%EmailAddr_\%% right into the To: field...

 

ListManager will remove the backslash automatically. If you sent this message to Bob, he would see:

 

Dear Bob,

Using merge tags in the To: field is easy! Just type %%EmailAddr_%% right into the To: field...

 

Note that you'll need to use the backslash any time you use a double percent sign.

 

Advanced Scripting and Mail Merge Tags

The Mail Merge tags described here aren't the only way of inserting custom content into your message. Conditional Content Commands allow you to insert content into your message depending on whether certain conditions are true for a particular recipient.

 

You can also take advantage of more powerful features using Advanced Scripting. Advanced Scripting expands upon the basic Mail Merge functionality, allowing you to leverage the power of the language Tcl to create highly customized messages.

 

In addition to the merge command outlined above, there are other procedures for inserting special content into your message. Merge and other procedures are fully documented in the ListManager Tcl Procedures section.

 

If you are using mail merge tags in your own custom Tcl script, It is important to note that the shortcut method of mail merge is a special case and is not valid Tcl. This means that you can't use just the field name anywhere else in a Tcl script other than as the argument to a procedure.

 

Obsolete Mail Merge Codes

ListManager versions 4.2 and lower used different tags to perform mail merge. E.g.: $subst('email.unsub'). These tags were replaced with the current codes in versions 5.0 and higher. Generally, these legacy codes may be translated by replacing $subst(' with %%merge and the final ') with %%. For example, $subst('email.unsub') is now %%merge email.unsub%%. Many legacy tags were made "short tags" that do not require the word "merge" to work, so %%email.unsub%% also works.

 

Although many of these legacy merge codes may work in later versions, not all will. Users upgrading from earlier versions should edit automated messages, headers and footers to use the updated tags.