addAttachment()
Last updated 4/03/2026
Definition
addAttachment() is a function on the Five object
that allows you to attach a file to an email generated during a mail merge process.
It can only be used within a function attached to the Do Merge Record event for a mail merge record. The function must be executed before the email is sent, as it appends the attachment/s to the outgoing email during the merge process.
This enables dynamic attachment generation per record, for example, attaching a generated PDF, invoice, or report specific to the recipient.
Available: Server
Function Signature
addAttachment(attachment: string, name: string) : FiveError;
| Parameter | Type | Description |
|---|---|---|
attachment | string | A Data URI-encoded file represented as a string |
name | string | The display name of the attachment as it will appear in the email |
Return Value
A FiveError object which can be investigated to know if the call was or was not successful.
Examples
addAttachment()