1

I've written AmpScript to generate a Signature line. When the amp script is placed directly into the HTML content area of an email, it works and does not display any extraneous code.

I placed this AmpScript into an HTML content block so that we could reuse it across several emails.
Within the emails, I'm outputting the block by using this line of code:

%%[ set @output = ContentBlockbyID("13210") output(concat(treatascontent(@output))) ]%%

When displayed by calling the block, it shows ctrl:eval/> on preview of the email. Is there something else I need to do in order to get the AmpScript to work in a Content Block.

%%[
/*These are set from the sendable data extension in this case progressive grid*/
Var @Email, @Stage, @title, @address, @sigemail, @zip, @fullname, @ContactOwner, @profileimage, @DynamicFromEmail, @DynamicFromName, @licensingpublicdisplay 
Set @Email = Email
Set @Stage = Stage
Set @ContactOwner = [Contact Owner: Full Name] 
Set @ContactOwnerEmail = [Contact Owner: Email] 
set @DynamicFromEmail = [Contact Owner: Email] 
set @DynamicFromName = [Contact Owner: Full Name] 

/* Lets look up the title and set the value from our signature line data extension */

/*Set the Title*/
Set @title = Lookup("Signature Line 2", "Title", "Email", @ContactOwnerEmail )
/*Set the Address*/
Set @address = Lookup("Signature Line 2", "address", "Email", @ContactOwnerEmail )
/*Set the City*/
Set @city = Lookup("Signature Line 2", "city", "Email", @ContactOwnerEmail )

Set @fullname = Lookup("Signature Line 2", "Full Name", "Email", @ContactOwnerEmail )

set @profileimage = URLEncode(Lookup("Profile Images by Contact", "Photo", "Full Name", @ContactOwner))

if ((@profileimage == "") OR EMPTY(@profileimage)) then
 set @profileimage = URLEncode('http://image.homestarfc-connect.com/lib/fe8913727c62037b74/m/1/cae2521b-3406-4292-80e0-45189fbca0fe.png')
endif

/*Set the ZipPostal Code*/
Set @zip = Lookup("Signature Line 2", "Zip_Postal_Code", "Email", @ContactOwnerEmail)

/*Set the Mobile*/
Set @mobile =  Lookup("Signature Line 2", "mobile", "Email", @ContactOwnerEmail)

/*Set the Phone*/
Set @phone =  Lookup("Signature Line 2", "phone", "Email", @ContactOwnerEmail)

/*Set the Fax*/
Set @fax =  Lookup("Signature Line 2", "fax", "Email", @ContactOwnerEmail)

/*Set the Email*/
Set @sigemail = Lookup("Signature Line 2", "email", "Email", @ContactOwnerEmail)
/*Set the Website*/
Set @website =  URLEncode(Lookup("Signature Line 2", "website", "Email", @ContactOwnerEmail))


/*Set the Licensing Public Display*/
Set @licensingpublicdisplay = Lookup("Signature Line 2","licensing public display","Email", @ContactOwnerEmail)

]%%



<img width="125" alt="Picture" src="%%=v(@profileimage)=%%">
<div>

  %%[ if not Empty(@fullname) then ]%%
  <i>%%= v(@fullname) =%%</i><br>
  %%[ endif ]%%

   %%[ if not Empty(@title) then ]%%
  <strong>%%= v(@title) =%%</strong><br>
   %%[ endif ]%%

    %%[ if not Empty(@phone) then ]%%
  <strong>Phone:</strong>%%= v(@phone) =%%<br>
    %%[ endif ]%%

    %%[ if not Empty(@sigemail) then ]%%
  <strong>Email:</strong>%%= v(@sigemail) =%%<br>
      %%[ endif ]%%

      %%[ if not Empty(@fax) then ]%%
  <strong>Fax:</strong>%%= v(@fax) =%%<br>
   %%[ endif ]%%


     %%[ if not Empty(@address) then ]%%
  <strong>Address:</strong>  %%= v(@address) =%%  
    %%= v(@city) =%% %%= v(@state) =%% <br>
   %%[ endif ]%%

  %%[ if not Empty(@website) then ]%%
  <strong>Website:</strong>%%= v(@website) =%%
   %%[ endif ]%%



     %%[ if not Empty(@licensingpublicdisplay) then ]%%
    <strong>Licensing Display:</strong>
    %%= v(@licensingpublicdisplay) =%%

 %%[ endif ]%%
</div>
  • Are you using server-side JavaScript in your email? – Adam Spriggs Aug 18 '17 at 20:19
  • No Im not using any other scripts in the emails. – Julie Beck Aug 19 '17 at 0:12
  • What about the template or another content area? I ask because ctr:eval/> is a SSJS fragment. – Adam Spriggs Aug 19 '17 at 18:51
  • No, all we have in the templates/content areas are a few images from content builder and basic text in an html block. – Julie Beck Aug 19 '17 at 19:55
0

After submitting a ticket to Salesforce, I was able to resolve this. The correct syntax to use is as follows:

%%[ 
Set @Output=ContentBlockByID("13210")
Set @Content=Concat(treatascontent(@Output))
]%%
%%=v(@Output)=%%
| improve this answer | |
  • To retrieve the stored content area you also could have used %%=ContentareaById("13210")=%% in an otherwise empty HTML content block. That works quite well and with the coming release the MC will give you a new content type to achieve this sort of content retrieval. Be careful, however, if you are running automated campaigns: all those retrieval methods will pull in the referenced content area as it is at the time of send. So make sure to thoroughly test code/content changes in a safe copy and update only after you made sure it works. Never develop in content areas retrieved at send time! – Stephan de Paly Aug 21 '17 at 22:02
  • Can't seem to edit my comment. I meant %%=ContentBlockById("13210")=%% – Stephan de Paly Aug 22 '17 at 8:18

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.