Home | Dynamic Content | Seamless Personal Greetings for Emails

Seamless Personal Greetings for Emails

It’s fairly easy to supply a Lead or Contact’s first name in an email. You can just use the dynamic content drop downs and select “first name” for each.

Dear ${Recipient.lead.firstname[0]!""}
${Recipient.contact.firstname[0]!""},

The above will turn into “Dear Sarah,” for example, for a Lead or Contact whose name is provided. This works great except for the in case where no first name was provided. For anyone whose name isn’t filled in in CRM yet, this will be the result:

“Dear ,”

This can be a bit unflattering, especially with the space hanging at the end. In this case you may wish to supply another greeting such as “Dear Sir/Madam.” If you’re sending to only Leads or only Contacts, this is easy. You can supply your fallback value within the quotes of the dynamic call:

${Recipient.lead.firstname[0]!"Sir/Madam"}

This will print out “Dear Sarah,” or “Dear Sir/Madam” if the Lead doesn’t have a first name. As I mentioned, this doesn’t work with both Leads and Contacts. Basically, if the script can’t pull in the Lead’s first name, it will print the fallback value. If the email doesn’t go to a Lead, but a Contact, then, there will never be a first name to supply for that Lead, so the fallback value will be used.

Therefore this

Dear ${Recipient.lead.firstname[0]!"Sir/Madam"}
${Recipient.contact.firstname[0]!"Sir/Madam"},

can become

“Dear Sir/MadamSarah,” “Dear SarahSir/Madam,” or even “Dear Sir/MadamSir/Madam”!

To send to both Leads and Contacts and consistently supply the right value, I developed the following script:

<#assign cemail=Recipient.contact.donotbulkemail[0]!"null">
<#assign contactname=Recipient.contact.firstname[0]!"null">
<#assign lemail=Recipient.lead.donotbulkemail[0]!"null">
<#assign leadname=Recipient.lead.firstname[0]!"null">
<#if cemail=="Allow" && contactname!="null">
${Recipient.contact.firstname[0]!""}
<#elseif cemail=="Allow">
Sir/Madam
<#elseif lemail=="Allow" && leadname!="null">
${Recipient.lead.firstname[0]!""}
<#elseif lemail=="Allow">
Sir/Madam
</#if>

For those sending to Leads and Contacts, you can use this as-is, (make sure to always “Paste As Plain Text”), but for those of you who may be curious, I’ll quickly break down the logic. First, I just set up a few variables. To determine whether the email is going to a Lead or a Contact, I chose a field that should always have data for each record. Therefore, if a Contact has data in that field, then we know the email is going to a Contact, and the same for Leads. I chose the “Do Not All Bulk Email” field. This field should always have a value (radio buttons must be set to one of their two values). Furthermore, the value should also always be “Allow”, otherwise the Lead or Contact would be excluded from the mailing!

Now that we’ve determined if the Lead or Contact is getting the email, we’ll check to see if they have their first name in CRM by checking to make sure that there is something filled out in their first name field. If so, we print the name. So IF the recipient is a Contact and IF the Contact has the first name field filled out, print their first name.

If the first step failed, then one of the above conditions was not true. To even send the email, “Do Not Allow Bulk Emails” must be set to “Allow”. Therefore, it must be that there was no first name filled out. We use the Contact “Allowing Bulk Emails” as an indication that it is still a Contact getting the email. If so, then we fill out “Sir/Madam” instead of the name (because we know it doesn’t exist).

The same logic works for Leads; we finished the code by simply repeating the same steps for leads.

Written by Courtney Smith, Marketing Success Manager at ClickDimensions

 

About the Author:

Leave A Comment