Do you know If It is possible to assign a variable that has dynamic content on it?. Similar to:

Hi, Miguel your email is: %%=TreatAsContent(@email)=%%. 
Thanks for using our services Date %%Date%%.

And then access the variable @HTML that contains custom html and other variables and play with it?

Obviously SET @HTML BEGIN and SET @HTML END won´t work but I just wanted to know If there is any workaround for this.

2 Answers 2


It might be helpful to read over the official AMPScript Syntax Guide.

Here's an example:


var @email, @servicesDate
set @email = AttributeValue("email")
set @firstName = AttributeValue("firstName ")
set @servicesDate = AttributeValue("servicesDate")


Hi, %%=v(@firstName)=%%

Your email is: %%=v(@email)=%%. 

Thanks for using our services Date %%=format(@servicesDate,"MM/dd/yyyy")=%%.

Use %%[ and ]%% to delimit your AMPScript blocks, then reference variables with the %%=v(@varName)=%% syntax outside of the AMPScript block.

EDIT: You can always add HTML content to an AMPScript variable using the content area/block functions:


var @email, @servicesDate
set @email = "<h1>whee!</h1>"
/* OR */
set @email = ContentAreaByName("my contents\PATH\TO\YOUR\CONTENT")
set @firstName = AttributeValue("firstName ")
set @servicesDate = AttributeValue("servicesDate")


EDIT: There are some more complete examples here:

  • I think set @email = ContentAreaByName("my contents\PATH\TO\YOUR\CONTENT") will do the trick, thanks! Commented Jul 13, 2016 at 11:14

If i understand your question correctly, you would create a content block with the html inside of it and then call it in to the email using:


You'll find the ID of the content area by selecting it and clicking properties

You'll be able to use dynamic content and variables from the actual email inside the content block as long as they are defined above where you are calling in the content.

  • You can also use %%=ContentAreaByName("my contents\PATH\TO\YOUR\CONTENTAREA")=%%, which is easier to maintain. Commented Jul 12, 2016 at 14:04

You must log in to answer this question.

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