I am new to all this AMPScripting.

How can i pull a list of subject lines from a DE in to an email subject line using AMPScript that meet certain criteria?

any example will help

1 Answer 1


Its not too hard, so you're in luck!

If you want to have a dynamic subject line:

  1. At the top of your email, make an AMPscript block, like %%[ ]%%. Declare a variable, like VAR @subject

  2. Within that block, do all your logic that will set this dynamic variable.

  3. Make the subject of your email %%=v(@subject)=%% . This will populate at send time.

If you want to store your subject lines in a Data Extension and retrieve them dynamically:

  1. Your Sendable Data Extension should contain the Segment field: Sendable Data Extension
  2. Create your Data Extension to lookup the Subject Line from, it should contain Segment as the key. I named my DE "Subjectline Table":
    Subjectline Table

  3. In your email content, set your @Subject variable using the LookUp() function.

    Set @Subject = LookUp("Subjectline Table","SubjectLine","Segment",Segment)
  4. In your Email Properties, set the subject line to be %%=v(@Subject)=%% Email Properties

Hope this helps, good luck!

  • that sounds good i will have to try this out. basically it will be something like this subject line Segment sub1 1 sub2 2 sub3 3 etc... how would i then define which subject line will get pulled through?
    – Peter Ho
    Jun 4, 2014 at 16:02
  • You need to do a look up to figure out which segment you're looking at, using one of the AMPscript look up rows functions, then write something like an IF ELSE IF ELSE statement to set @subject based on that.
    – Timothy
    Jun 4, 2014 at 16:55
  • thanks. looking in the DE it only contains the email address and segment how can I code the AMPScrit. so if segment 1 you should get subject line 1 and so on.... any ideas
    – Peter Ho
    Jun 4, 2014 at 19:46
  • %%[ Var "at"subject, "at"segment Set "at"Subject = subject Set "at"segment = Trigger_Guide_Segment IF "at"segment = 11 then Set "at"subject = "test 11" Else IF "at"segment = 12 then SET "at"subject = "test 12" ENDIF ]%%
    – Peter Ho
    Jun 4, 2014 at 20:37
  • You will need to use == not just = for your IF comparison. Otherwise, its fine.
    – Timothy
    Jun 4, 2014 at 21:07

You must log in to answer this question.

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