0


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

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

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.

-1

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:

|improve this answer|||||
  • I think set @email = ContentAreaByName("my contents\PATH\TO\YOUR\CONTENT") will do the trick, thanks! – Miguel Puig Jul 13 '16 at 11:14
1

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:

%%=ContentArea("CONTENTID")=%%

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.

|improve this answer|||||
  • You can also use %%=ContentAreaByName("my contents\PATH\TO\YOUR\CONTENTAREA")=%%, which is easier to maintain. – Adam Spriggs Jul 12 '16 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.