Follow

Salutation First Name or Title + Last Name

Table of Contents

Question

I have a custom field called "title" and I want to personalize the salutation in the email sent to my subscribers as follows:

  • If first name exists, then print

Dear [first]

For example:  "Dear Mary,"

  • If the first name field is blank, then print

Dear [title] [last],

For example:  "Dear Ms. Richards,"

  • If both the first name and title fields are blank, then print

Dear Customer,

How do I code this in my template?

Answer

In versions 8.2 and later, the following code will check your subscriber's data and then print the saluation:

%%concat titleLast $title " " $last%% Dear %%if first != "" then printdata first else if title = "" then print "Customer" else if last = "" then print "Customer" else printdata titleLast%%,<br />

The first line merges the values in the subscriber's title and last name fields. 

The next line breaks down as follows:

  • Print "Dear "
  • If the first name is not blank, then print the first name
  • Else, if the title is blank, then print "Customer"
  • Else, if the last name is blank, then print "Customer"
  • Else, if neither the title or last name are blank, then print the merged value of the title and last name
  • Print ","

For earlier releases that do not support nested if/then/else use:

%%concat titleLast $title " " $last%%

Dear %%if first != "" then printdata first%%%%if first != "" then print "<!--"%%%%if title = "" then print "Customer<!--"%%%%if last = "" then print "Customer<!--"%%%%if title != "" then printdata titleLast%%%%if last = "" then print "-->"%%%%if title = "" then print "-->"%%%%if first != "" then print "-->"%%,<br />

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk