0

I set up sending an attachment in my email using an amp script.

%%[

var @customerKey, @fileAlias
set @fileName = "https://drive.google.com/file/d/1234567890/view?usp=sharing"
set @fileAlias = "Test_Attachments.pdf"

AttachFile("HTTP", @fileName, @fileAlias,4,5,6,7,true)

]%%

As a link from where the file should be taken, I indicated a link to google drive (having previously opened access to the file). Link above like example

But I'm facing a problem when an email arrives, the attachment won't open and the error "You may be offline or with limited connectivity. Try downloading instead" is thrown, while downloading the following error "Failed to load PDF document.".

What could be the problem? I did not find adequate examples of use.

1 Answer 1

1

When you use a share link to a PDF on Google Drive, the URL of that link does not actually go to the PDF file itself, but to a page displaying that PDF. For the attachfile function to behave correctly, you should point to the physical file itself.

Hence instead of linking to: https://drive.google.com/file/d/1234567890/view?usp=sharing you should link to something like: https://hosting.example.com/folder/Test_Attachments.pdf

I have tried to find a method for generating a direct file link in Google Drive, but I am afraid it is not possible (at least according to my super fast and superficial research). I suspect this is sown to how access management is being handled on Google Drive. Hence my advice will be to host the file elsewhere, where direct file links can be generated:

%%[
var @customerKey, @fileAlias
set @fileName = "https://hosting.example.com/folder/Test_Attachments.pdf"
set @fileAlias = "Test_Attachments.pdf"

AttachFile("HTTP", @fileName, @fileAlias,4,5,6,7,true)
]%%
1
  • Understood. Thank you!
    – Slavik
    Commented Aug 21, 2023 at 7:41

You must log in to answer this question.

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