enter image description hereI'm trying to add custom text (ie. "Dear User," instead of just "Dear ,") for the empty first name attribute while triggering the email.

Can anyone help me to fix this by using AMPscript ??

Getting error after adding this code.


SET @FirstName = FirstName

IF NOT EMPTY(@FirstName) THEN SET @Salutation = CONCAT(Dear,CONCAT(" ", @Firstname)) ELSE SET @Salutation = "Dear User"



Super simple.


SET @FirstName = [First Name]

SET @Salutation = CONCAT("Dear ", @FirstName, ",")
SET @Salutation = "User"

Then in content you just add %%=v(@Salutation)=%%


<table><tr><td>Dear %%=v(@Salutation)=%%,</td></tr></table>
  • It throws me an error.. I'm sending through guided send by using list. – Mohammed Feb 2 '16 at 15:13
  • 1
    sorry forgot to close the if statement. will update code accordingly – Gortonington Feb 2 '16 at 15:21
  • :( Again Error. Error 1: Script SET Statement Invalid An Error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: CONCAT(Dear,CONCAT("",!Firstname)) MemberID:****** JobID:0 The specified attribute or custom object name was not found for this client....... – Mohammed Feb 2 '16 at 15:35
  • concat line should be set @saluation = concat("Dear ",@FirstName) – Adam Spriggs Feb 2 '16 at 15:54
  • was rushing again, forgot the " around dear. – Gortonington Feb 2 '16 at 15:59

I tend to do it this way:


var @FirstName
set @FirstName = AttributeValue("First_Name") /* handle null gracefully */

Dear %%=iif(empty(@FirstName),"User",@FirstName)=%%,
  • User text comes for all the subscribers. – Mohammed Feb 2 '16 at 15:58
  • It shouldn't if your sending Data Extension or List has a column or Attribute named FirstName. – Adam Spriggs Feb 2 '16 at 22:41
  • Thanks Adam. I've checked the Data Extension property and the field name is set to "FIRST_NAME". So I've to modify to something like this right ? i.e SET @FirstName = FIRST_NAME Thanks again. :) – Mohammed Feb 3 '16 at 10:14

You have two MAIN OPTIONS when deciding on salutations.

Assuming the first name column on your data extension is called "FIRST_NAME".

OPTION 1. When first name is blank in your data extension, and you want to add a default name so you never get a "Dear ," scenario.

Dear %%[if not empty(FIRST_NAME) then]%%%%FIRST_NAME%%%%[else]%%Client%%[endif]%%,


OPTION 2. You want to simply hide the salutation altogether when the first name is blank and simply begin the first paragraph. Note: You will most likely want a line break so you need to add two HTML breaks immediately after the comma.

%%[if not empty(FIRST_NAME) then]%%Dear %%FIRST_NAME%%,%%[endif]%%

While you could create variables and use set commands in an AMPscript block, not sure that approach makes the most sense here. I personally save these two options as HTML code snippets and add them on the fly as needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.