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.
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
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")=%%.
]%% 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 contentsPATHTOYOURCONTENT") set @firstName = AttributeValue("firstName ") set @servicesDate = AttributeValue("servicesDate") ]%%
EDIT: There are some more complete examples here:
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0