Skip to main content
Skip table of contents

Salutation First Name or Title + Last Name

Question

I have a custom field called "title" and I want to personalize the salutation in the email sent to my contacts 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

The following code will check your contact's data and then print the salutation:

%%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%%,

The first line merges the values in the contact'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 ","


 

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.