Sending multiple email attachments via Marketing Cloud dynamically

marketing-cloud

I want to send multiple attachments via Marketing Cloud. We have the Attachment feature enabled and the below code works for a single attachment. However I wanted to attach multiple attachments based on subscriber ID, as we have a Data Extension (Invoices) that has SubscriberKey, Invoice number and date. We invoice monthly and would like to send all invoices related to a Subscriber Key in one email. Is this possible to do?

Our invoices are of minimal size, so we are not worried about file size, as the most we would have attached is 5 invoices to one subscriber key.

Any help would be appreciated!

%%[

var @invoiceid
var @fileName

set @invoiceid = AttributeValue("invoiceid")
set @fileName = concat("invoice_", @invoiceid, ".pdf")

AttachFile("FTP", @fileName, @fileName)

]%%

Best Answer

If you have many attachments, I would consider a loop. Lookup all the rows in the Invoice Data Extension and attach the files. How to do this has been described here.

If it is just a few attachments, I would just add the different attachments to the sending data extension: Attachment_1, Attachment_2 and conditionally (If not empty) duplicate the attachment code you already have as described here.

Good luck!

Related Topic