Skip to main content
If the shop does not send its emails itself but via an external mail system, it does not send that system the finished email, but the data from which the system builds the email. There is a separate template for this, stored as ExternMailTemplate. The attachments are the part of this data that cannot simply be passed on as text. The MAIL- tags provide them: for each attachment, the file name, the type of attachment and the content in Base64 encoding. The shop system maintains two separate lists. One contains the file attachments, the other the attachments generated from an HTML template. Both are treated the same, and each has its own four tags. Guide: Sending shop emails via an external mail system

Looping through the attachments

MAIL-FileAttachment and MAIL-HTMLAttachment are loops over the respective list. As area tags, they check whether any attachments of this type exist at all.
The same applies to the HTML attachments with MAIL-HTMLAttachment.
The two tags are not single tags. ~MAIL-FileAttachment~ outputs nothing and is treated as an invalid tag. You retrieve the details of an attachment exclusively via the three suffix tags, and only within the loop.
The three suffix tags strictly require the loop. If they are only inside the area tag {MAIL-FileAttachment} without the loop in it, the shop system accesses an entry before the start of the list. The result is undefined. Therefore, always open {@MAIL-FileAttachment}.

The details for each attachment

The HTML variants are named accordingly MAIL-HTMLAttachment_Name, MAIL-HTMLAttachment_Type and MAIL-HTMLAttachment_ContentB64.

The types of attachments

The type lets you treat attachments differently in the passed data record, for example to name the SEPA mandate differently from a data sheet. The shop system itself does not distinguish by type when sending.
ContentB64 always returns the content Base64-encoded, even for the HTML attachments, whose content is actually text. The external mail system thus gets the same format for both lists.

The loop only runs once

After the pass, the shop system empties the list. A second loop over the same attachments returns nothing, and the area tag {MAIL-FileAttachment} no longer takes effect afterward either. Both lists behave this way, each on its own.This determines the order in the template: check first, then loop. If you still need to know after the loop whether there were attachments, store that beforehand in a design parameter.
Reference: DC- (Parameters)

The tags at a glance

All tags apply exclusively in the template for the external mail system. On other templates, the attachment lists are not available, and the tags remain unresolved.
  • Guide: Sending shop emails via an external mail system
  • Guide: Designing shop emails
  • Reference: DC- (Parameters)