My Creative team provided the HTML and I uploaded the code in marketing cloud and used it for creating an Email message (type HTML). This Email will be sent every 15 days. But the use case is- Every 15 days when this email will be sent, following things will be new in the HTML-

  1. 4 -header links(heading as links- Heading text and its corresponding href's will be change)
  2. Image as link(one Img src and its corresponding Href, both these things will change)
  3. Read more Button(HTML/CSS for button remains same- but href changes)

Without manually going in the HTML each time to change these things, is it possible to handle this change in content using Amp script.

I would like to explain what I have tried till now.

I have created a non sendable DE, with 3 columns- Content, Links, Lookupfield. "Content" column contains value of the Content part of the email like - text heading,image scr etc. "Links" column contains the corresponding Href's . Lookupfield column is having a default value set to 0 during DE creation.( this field will be used for pulling rows using lookuprow() function). Here is how my DE looks like : enter image description here

Also the Ampscript I have written is :

VAR @em_content,@target_links,@rows,@rowCount,@i,@row
SET @em_content = AttributeValue("Content")
SET @target_links = AttributeValue("Links")
set @rows = LookupRows("DE_ForDynamicContent","LookupField", 0)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

Output(Concat("rowCount is: ", @rowCount))

  for @i = 1 to @rowCount do
    set @row = row(@rows, @i) /* get row based on counter */
    set @em_content = field(@row,"Content")
    set @target_links = field(@row,"Links")

%%[ next @i ]%% 

%%[ else ]%%

No rows found

%%[ endif ]%%

Also one of the things that I am not sure of- where should these three amp script lines be placed in the HTML?

1. %%[ next @i ]%% 

2. %%[ else ]%%

    No rows found

3. %%[ endif ]%%

OR should all ampscript can reside together in one codesnippet?

Hi @VijayaKapadam , In would like to share that I modified my DE , its like this now enter image description here

Also the Ampscript added in my HTML email

%%[ SET @UniqueSendID="Test_Send1" SET @ImgSource=Lookup("DE_ForDynamicContent_NewVersion", "ImgSource", "UniqueSendID", @UniqueSendID) SET @ImgHref=Lookup("DE_ForDynamicContent_NewVersion", "ImgHref", "UniqueSendID", @UniqueSendID) SET @HeaderLinkText1=Lookup("DE_ForDynamicContent_NewVersion", "HeaderLinkText1", "UniqueSendID", @UniqueSendID) SET @HeaderLinkHref1=Lookup("DE_ForDynamicContent_NewVersion", "HeaderLinkHref1", "UniqueSendID", @UniqueSendID) SET @ReadMoreHref1=Lookup("DE_ForDynamicContent_NewVersion", "ReadMoreHref1", "UniqueSendID", @UniqueSendID) SET @HeaderLinkText2=Lookup("DE_ForDynamicContent_NewVersion", "HeaderLinkText2", "UniqueSendID", @UniqueSendID) SET @HeaderLinkHref2=Lookup("DE_ForDynamicContent_NewVersion", "HeaderLinkHref2", "UniqueSendID", @UniqueSendID) SET @ReadMoreHref2=Lookup("DE_ForDynamicContent_NewVersion", "ReadMoreHref2", "UniqueSendID", @UniqueSendID) SET @HeaderLinktext3=Lookup("DE_ForDynamicContent_NewVersion", "HeaderLinktext3", "UniqueSendID", @UniqueSendID) SET @HeaderLinkHref3=Lookup("DE_ForDynamicContent_NewVersion", "HeaderLinkHref3", "UniqueSendID", @UniqueSendID) SET @ReadMoreHref3=Lookup("DE_ForDynamicContent_NewVersion", "ReadMoreHref3", "UniqueSendID", @UniqueSendID)


Also I am displaying the content as per your suggestion using redirect() to and v() function.

Can you share what code can be added for fallback scenerio?

  • 2
    Yes, using AMPScript in this use case to update URLs is possible. Please outline what you have tried so far and the problem faced for anyone to help. Your clues are to capture URLs needed in a structured manner within a data extension and, using AMPScript, reference them in your email. Jul 19 at 22:27
  • Hi @VijayaKapadam thanks for sharing feedback. I have updated in my question now, details of what approach I have taken till now. Jul 20 at 15:01
  • Hi I have gone through the solution that you suggested. I have few queries based on that. I am not clear about the structure of my DE that you suggested here. Can you share here exactly how many columns should I have in my DE and structure that mentioned below, are those column's name? Also , can you brief me about the UniqueSendID. How to get this unique each time in the Data extension. Is it coming from CSV . Also the amp script statement SET @UniqueSendID = "July_2ndHalf_2023" , can you please suggest, do i have to change this manually each time in my email. Jul 24 at 18:47
  • Hi Prerna, Based on your original query, I recommended creating these fields in DE. This can be adjusted as per your needs. UniqueSendID;HeaderLinkText1;HeaderLinkHref1;HeaderLinkText2;HeaderLinkHref2;HeaderLinkText3;HeaderLinkHref3;HeaderLinkText4;HeaderLinkHref4;ImageSrc;ImageHref;ReadMoreHref The Idea of UniqueSendID is to distinguish each send you perform and the content used for those sends. For example, you can add another row to DE with 'August_1stHalf_2023' with the dynamic link details added to the fields corresponding to the row. Jul 25 at 1:36
  • Once you add a new row to DE all you need to make sure the AMPscript in the email is to updated with the right the UniqueSendID for each send. Jul 25 at 1:36

1 Answer 1


You can design your basic solution as below. This is a no-frills version.

Data Extension: I recommend you update "DE_ForDynamicContent" DE to follow below structure


UniqueSendID: To store the dynamic content for each send cycle. For Example, it can have a key like "July_2ndHalf_2023". Ensure that each send has a distinct UniqueSendID, for example next send could be 'August_1stHalf_2023' and so on.

AMPscript in Email: In your email's HTML code, use AMPscript to fetch the dynamic content based on UniqueSendID for each email send. And make sure you update this UniqueSendID each time for a new send to pick up right links from the DE. You can do it something along the lines of:

    /* Fetch the dynamic content for the current cycle using the unique UniqueSendID */
    SET @UniqueSendID = "July_2ndHalf_2023" /* Replace with actual GUID for the current cycle of email send */
    /* Fetch the dynamic content for the current cycle from the Data Extension */
    SET @headerLinkText1 = Lookup("DE_ForDynamicContent", "HeaderLinkText1", "UniqueSendID", @UniqueSendID)
    SET @headerLink1Href = Lookup("DE_ForDynamicContent", "HeaderLinkHref1", "UniqueSendID", @UniqueSendID)
    SET @headerLinkText2 = Lookup("DE_ForDynamicContent", "HeaderLinkText2", "UniqueSendID", @UniqueSendID)
    SET @headerLink2Href = Lookup("DE_ForDynamicContent", "HeaderLinkHref2", "UniqueSendID", @UniqueSendID)

    /* Fetch other fields as required */   

Update HTML in your Email:

    <!-- Replace the header links -->
    <a href="%%=RedirectTo(@headerLink1Href)=%%">%%=v(@headerLinkText1)=%%</a>
    <a href="%%=RedirectTo(@headerLink2Href)=%%">%%=v(@headerLinkText2)=%%</a>

    <!-- Add other field references to use AMPscript variables -->

Fallback Scenarios: Implement fallback code to handle scenarios where the current send cycle's dynamic content is unavailable. This will ensure that the email still renders correctly.

Test and Test again

You must log in to answer this question.

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