Skip to main content
Version: 1.4.x

Email Attachments

You can send attachments with your emails. This works for both templated emails and hardcoded emails.

How to send email attachments with Engagespot?

In the data payload of your send notification request (API or SDK), include an attachments array which can contain one or more attachment objects as mentioned below.

{
"content":"base64 encoded file content (Max - 10MB)",
"name":"Filename for example - sample.pdf",
"contentType":"MIME Type of attachment for example - application/pdf",
"attachmentKey":"attachmentKey"
}

What is attachmentKey?

The attachmentKey is a unique identifier assigned to an attachment within an email template. It serves as a reference to associate a specific attachment with the corresponding email template, particularly when you are triggering a workflow that involves multiple email templates. By using the attachmentKey, you ensure that the right attachment is linked to the correct email, enabling accurate and organized handling of attachments across different templates in a workflow.

How to Configure attachmentKey in an Email Template?

To configure the attachmentKey in an email template, follow these steps:

  1. Access the Email Template Editor: Start by navigating to the email template editor page in your workflow .

  2. Assign the attachmentKey: Within the attachment settings, there will be an option to assign a unique attachmentKey to each attachment. Enter a distinctive value that will act as the identifier for this attachment within the template.

  3. Save the Changes: Once the attachmentKey is set, ensure that you save your changes. Engagespot will now recognize this key as the unique identifier for the attachment whenever the template is used in a workflow.

  4. Use in Workflows: When triggering workflows that involve multiple email templates, Engagespot will use the attachmentKey to correctly identify and attach the specified files to the relevant email templates, ensuring seamless execution.

Here is a full example of send notification request with attachment.

const { EngagespotClient } = require('@engagespot/node');

const client = EngagespotClient({
apiKey: 'YOUR_ENGAGESPOT_API_KEY',
apiSecret: 'YOUR_ENGAGESPOT_API_SECRET',
});

client.send({
notification: {
templateId: 485729,
},
data: {
attachments: [
{
content:
'JVBERi0xLjMNCiXi48/TDQoNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL091dGxpbmVzIDIgMCBSDQovUGFnZXMgMyAwIFINCj4+DQplbmRvYmoNCg0KMiAwIG9iag0KPDwNCi9UeXBlIC9PdXRsaW5lcw0KL0NvdW50IDANCj4LjI1MDAgNjA0Ljk0NDAgVGQNCiggbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiBBbmQgbW9yZSB0ZXh0LiA==',
name: 'sample.pdf',
contentType: 'application/pdf',
attachmentKey: 'attachmentKey',
},
],
},
recipients: ['unique-user-id'],
});