I'm working on getting one data extension to display for 3 email templates using content builder. Each email template will have different content within it, but I only want 1 email template to be sent to those on the data extension who meet my requirement.

My Data extension has the following columns:

Bob       Smith     blue
Billy     Idol      blue
Andrew    Cowel     red
Jane      Doe       red
Jenny     Rodgers   green
Pat       Martinez  green

I want the following to happen:

Email template 1 to send only to emails that have the color blue in their row (but not to send to red or green)
Email template 2 to send only to emails that have color red in their row (but not to send to blue or green)
Email template 3 to send only to emails that have color green in their row (but not to send to blue or red)</blockquote>

I've seen this done with the Dynamic blocks within content builder, but I wanted to achieve this with my own ampscript code, if possible.

1 Answer 1


You need to read the data for the current subscriber using AMPscript Lookup-function and add an if-statement which checks the value of the color-column.

This is very easy if your dataextension contains the email address or the subscriberkey, as the correct row could be identified properly then. If only the names are used to identify the row, duplicates could be possible.

Example for the code-snippet you will need:

    SET @color = Lookup("YourDataExtension", "COLOR", "NameOfSubscriberKeyColumn", _subscriberkey)

    IF @color == "blue" THEN 
    <!-- your html code for blue here -->
%%[ ELSEIF @color == "red" THEN ]%%
    <!-- your html code for red here -->
%%[ ELSE ]%%
    <!-- your html code for green here -->
%%[ ENDIF ]%%

These resources should be helpful for you:

  • This is quite helpful, however, I will have 3 seperate templates each with hard coded content within Journey Builder. So I need template 1 to only be sent out to those on my list with color blue. And as the system analyzes the data extension for send of template 1, it doesn't send for red or green. Is there a "null" or stop send option where color=blue is false Thank you! Side Note: I do have emails address and subscriberkeys in this list, I just left them out of the example for simplicity.
    – JMStelter
    Mar 2, 2017 at 15:21
  • 1
    AMPscript can just only be used inside the email, so this cannot be achieved using AMPscript if you have separate emails/templates. If you want to send separate emails from within journey builder, you can just add a decision split checking the color and leading to one separate path for each color. For more information check out the documentation: help.marketingcloud.com/en/documentation/journey_builder/… Mar 2, 2017 at 15:34
  • sorry, I made a typo. We're sending this by using content builder, not journey builder. Our old way used the HMTL paste, but we are trying to include non-technical people in this process so we want to make this as easy as possible.
    – JMStelter
    Mar 2, 2017 at 15:50
  • However this doesn't change the problem, that AMPscript can only be used inside an email and an email send from within content builder is always based on one single email, rather than multiple emails. So I guess this isn't possible this way or at least I don't know how this could be achieved. Mar 2, 2017 at 16:56

You must log in to answer this question.

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