Sending Attachments with Templates

April 28, 2017 Contributors

For sending attachments with templates you have a few different options:

When sending messages using the SparkPost REST API, the message body can be specified either “inline” as part of the transmission request or by referring to a stored template.  When using an inline template, you can specify attachments to include in the final message through the content.attachments attribute.  However, when using a stored template, the content.attachments attribute is not available.

If you have a fixed attachment to include within a stored template, you can embed it within the template by populating the template’s email_rfc822 attribute with a preformed multipart message. In this context, a fixed attachment is one which is the same for all deliveries and recipients.

For more details on using the template email_rfc822 attribute, check out the templates API reference and this blog post on advanced template usage.