0

I'm trying to attach a file with AttachFile AMPScript but looks like I'm missing something.

here is my code:

%%[
  set @billingUrl = RequestParameter("billingUrl")
]%%

<!-- it works, but I need the request params value --> 
%%= AttachFile('HTTP', 'http://example.com/static-url.pdf') =%%

<!-- it doesn't work and do not send emails -->
%%= AttachFile('HTTP', v(@billingUrl), 'fatura.pdf') =%%
or 
%%= AttachFile('HTTP', @billingUrl, 'fatura.pdf') =%%
or 
%%= AttachFile('HTTP', {{billingUrl}}, 'fatura.pdf') =%%


<!-- it works -->
url: %%=v(@billingUrl)=%%  

<!-- it works -->
url: {{billingUrl}}

What am I missing here?

  • do you have attachments enabled on your account? – Samuel Dare Apr 2 '18 at 23:26
  • @Data_Kid yes man! It's available. I've updated the example showing what works. – lucianosousa Apr 3 '18 at 13:42
  • How are you passing the billing url to the page? %%= AttachFile('HTTP', v(@billingUrl), 'fatura.pdf') =%% wont work as that how you call the value of a variable from outside the block not within it – Samuel Dare Apr 3 '18 at 14:29
  • Try putting the variable in quotes e. g %%= AttachFile('HTTP', '@billingUrl', 'fatura.pdf') =%% – Samuel Dare Apr 3 '18 at 14:38
1

For those who are looking for the answer, I've found this way to make it works.

%%
  [
    Var @billingUrl
    Set @billingUrl = TreatAsContent('{{billingUrl}}')
  ]
%%

%%=AttachFile('HTTP', @billingUrl)=%%

Looks like RequestParameter("billingUrl") didn't work as expected

0

You might want to enable the AttachFile ampscript via account manager. This is a paid feature and is charged per 1000 attachments.

Please refer to this link

Thanks

Chandan

  • It's available. I've updated the example showing what works. – lucianosousa Apr 3 '18 at 13:41

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.