0

I am trying to use attachfile ampscript in conjunction with date personalization string. Please see below steps:

1: Data Extract Activity which exports the data from data extension with the file name ContactDetails%%Year%%-%%Month%%-%%Day%%.xlsx

2: File Transfer Activity which puts it into the import folder.

3: I use the attach file function %%=AttachFile('FTP','ContactDetails%%Year%%-%%Month%%-%%Day%%.xlsx','ContactDetails%%Year%%-%%Month%%-%%Day%%.xlsx')=%%

However when I receive the email instead of attached file I get the same ampscript %%=AttachFile('FTP','ContactDetails%%Year%%-%%Month%%-%%Day%%.xlsx','ContactDetails%%Year%%-%%Month%%-%%Day%%.xlsx')=%%

Please note that attach file function is enabled for the account. When I test the attach file as %%=AttachFile('FTP','20180221_New_CRM_Unsubscribers_Extract.txt','ContactDetailsTest.txt')=%%

I get the attachment successfully. Is there a way to use %%Year%%-%%Month%%-%%Day%% in attach file function.

Thanks

5

You can do something like this:

%%[

var @today
var @fileName

set @today = format(now(1),"yyyy-MM-dd")
set @fileName = concat("ContactDetails", @today, ".xslx")

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

]%%
3

Wildcards are not supported in AMPScript. You will need to generate the filename using Date Time AMPScript functions.

  • Now() to get the current system date and time
  • DatePart() to get a specified part of a date. You will need DAY, MONTH and YEAR
  • Concat() to construct the filename from 'ContactDetails', 'YEAR', 'MONTH', 'DAY'..

Then use AttachFile() with the filename to attach the file.

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.