AMPscript 101
This scenario includes information on these aspects of using AMPscript:
- Creating variables in AMPscript
- Using variables to set values in a data extension
- Print the values of variables to the screen
This AMPscript provides the content for the entire email message:
A code block declaration sets off the first part of the AMPscript - %%[ and ]%% - because that AMPscript spans over several lines located between the "/_ 101 _/" comments. The subscriber does not see the results of these variables yet. The Var command creates the variables named in that line of code, each separated by a comma. The Set commands give the variables the value of the information taken from a column in the data extension associated with the send.
Inline code declarations set off the AMPscript within the email text - %%= and =%% - because the AMPscript refers to a variable that belongs to a single line of text within the email. In the email, information from the data extension associated with the email send replaces the AMPscript declarations.
From here, paste the AMPscript into a content area:
This image displays the text version of the same email:
To test your email with the data extension you use for the actual send, click Send Preview and select the data extension from your available send options.
Choose a test recipient to start your preview with and click Generate Preview. You will see the information the AMPscript pulled from the data extension placed into the email:
Click the arrow keys to cycle through the other rows in the data extension. You see the fields change depending on the row selected. Send the email job after you complete the process. Each email you send includes information from the row associated with that subscriber.