1

So I'm writing an HTML email with attachments. The thing is I'm trying to find out if I can set up dynamic attachments based on the content of a Data Extension.

My Data Extension looks like this:

Attachment Customer Key Attachment Name EmailAddress Username
myContactKey12345 Document1 [email protected] Jason
myContactKey09887 Document2 [email protected] Craig

I have two Documents in Content Builder and I've modified the Customer Key for each of those attachments to match the values in the table above. So, for example, Document1 customer key is myContactKey12345 in Marketing Cloud.

I want to send emails such that attachments are unique to the email address I'm sending to.

So, for example, I want to send Sample Email 1 to [email protected] but I only want Jason to receive Document1. I want to send the same Sample Email 1 to [email protected] but I only want Craig to receive Document 2.

This is the ampscript I've tried using and while it doesn't give me any errors during preview and test, when I send a test email I don't ever receive that test email.

Can I even do something like this? Is doing it with ampscript not the solution I'm looking for?

%%[
SET @attachmentkey = attachmentKeyFromDE
AttachFile('ContentBuilder', "%%=v(@attachmentkey)=%%", "document.pdf")
]%%
0

1 Answer 1

0

Firstly, you need to ensure that File Attachments have been included in your license from Salesforce? Thus is billed separately from supermessages, and is a similar measure, where you are paying for the number of attachments you send. It is not possible to validate this in the platform itself, so if your sends still keep failing, I will reach out to your Salesforce Account Executive to validate this.

Secondly, there is a small issue in your code. You are mixing inline and block Ampscript:

%%[
SET @attachmentkey = attachmentKeyFromDE
AttachFile('ContentBuilder', "%%=v(@attachmentkey)=%%", "document.pdf")
]%%

This should instead be:

%%[
SET @attachmentkey = attachmentKeyFromDE
AttachFile('ContentBuilder', @attachmentkey, "document.pdf")
]%%
1
  • 1
    Thanks, this solved the issue. I feel like I tried this before and it threw me an error but I also tried a bunch of variations just to find what wouldn't give me a straight up error during preview. I probably just messed it up a bunch, thank you though!
    – jonq
    Commented Jan 9 at 15:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .