1

We're building an email template in Marketing Cloud Email Studio where we're passing the HTML content of the email dynamically as subscriber value.

The template looks simply like

%%=AttributeValue('email_contents_html')=%%

Now, we're trying to add email attachments but trying to figure out best way to do this.

Adding an Ampscript block like below to the template works just fine:

%%[ 
var @fileName, @fileAlias
set @fileName = "http://www.africau.edu/images/default/sample.pdf"
set @fileAlias = "test.pdf"
AttachFile('HTTP', @fileName,@fileAlias)
]%%

But we're looking at bit more dynamic control over the attachments and having ability to pass them dynamically to marketing cloud.

We've tried adding the ampscript block to the html code we're sending (email_contents_html subscriber attribute), but that just results in script rendered inline in the content and not executed.

Is there any way to accomplish what we're trying to achieve here, i.e. being able to pass Ampscript block to be executed in the email as part of subscriber attributes or something else from outside the marketing cloud?

1

You need to wrap your content into TreatAsContent function call. Only this way, the ampscript held in the email_contents_html will be processed.

%%=TreatAsContent(AttributeValue('email_contents_html'))=%%

In your current code, it is simply treated as simple text, and displayed without being processed at all.

1
  • Thanks! That worked like a charm, exactly what we needed
    – Tom Dracz
    Mar 16 at 12:01

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.