Attaches a file to an outgoing email message and can include a link to the file when you view the email as a web page. Contact your Marketing Cloud account representative to enable AMPscript email attachments for your account before using this function. You can also contact your account representative to adjust the error threshold that causes the send job to stop prematurely. This feature helps prevent a single error from stopping the entire job.
AttachFile(1, 2, 3, 4, 5, 6, 7, 8)
|1||string||Required||Location from which to pull files. Valid values include HTTP, FTP, Portfolio (for Classic Portfolio), or ContentBuilder (for Content Builder).|
|2||string||Required||Location from which to pull attachments. 2088 characters maximum. Specify a URL if you select HTTP. Specify the name of the file in the Import folder of your Enhanced FTP site if you select FTP. Specify the external key if you select Portfolio or ContentBuilder.|
|3||string||Name assigned to file when system attaches it to an email message. The function uses the original file name if you don't specify a new name. If you don't specify a value for the HTTP option, the function uses the Content-Disposition information from the HTTP header. If the server providing the file does not provide Content-Disposition information, the function uses an auto-generated value. For Content Builder, the file extension is dropped if you don't include the name and file extension.|
|4||boolean||Indicates whether a link to the attached file appears in View As A Web Page. Use only if string is HTTP.|
|5||string||URL of the attachment link to use for View As A Web Page. Use only if string is HTTP.|
|6||string||Text for attachment link used in View As A Web Page. Use only if string is HTTP.|
|7||int||Number of days the link appears in View As A Web Page. Use only if string is HTTP.|
|8||boolean||When true, changes the content-disposition from inline to attachment, when the default is inline.|
This example attaches a PDF document from a website to your outgoing email. The email also includes a link to the file in View As A Web Page with the text 'Click here to download your catalog.' That link expires from View As A Web Page after four days.
If you want to rename the attachment, enter the optional filename argument as shown below:
The next example attaches a Word document from the import folder of the Enhanced FTP site. It also concatenates a new filename from the recipient's full name and the string 'NewCatalog.doc' at the time of attachment.
The following file types can be attached to emails sent through Marketing Cloud:
|File Type||MIME Type|
This function supports secure transmission over HTTPS. If the remote server does not respond to the AttachFile() call within 30 seconds, the send reschedules for 15 minutes later and tries again.
You can only attach files contained in the account used to send the email message. This function does not support shared content from Content Builder or Portfolio.