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"


3 Answers 3


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
    Commented Feb 2, 2016 at 15:13
  • 1
    sorry forgot to close the if statement. will update code accordingly Commented Feb 2, 2016 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
    Commented Feb 2, 2016 at 15:35
  • concat line should be set @saluation = concat("Dear ",@FirstName) Commented Feb 2, 2016 at 15:54
  • was rushing again, forgot the " around dear. Commented Feb 2, 2016 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
    Commented Feb 2, 2016 at 15:58
  • It shouldn't if your sending Data Extension or List has a column or Attribute named FirstName. Commented Feb 2, 2016 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
    Commented Feb 3, 2016 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .