> For the complete documentation index, see [llms.txt](https://user.netmera.com/netmera-developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-a-transactional-email-with-attachments-and-parameters.md).

# Sending a Transactional Email with Attachments and Parameters

Send a panel email to a single recipient with file attachments and values from your own system filled into the template.

This recipe shows how to send an email that is defined in the Netmera panel to a single recipient, with one or more files attached and with placeholder values provided by your backend at send time. The template is prepared once in the panel; every send carries its own files and values.

## When to Use

This recipe fits one-to-one emails that deliver a document together with personalized content, such as an invoice with its date, a monthly statement, or a report that is ready to download.

## Prerequisites

* REST API key of the application
* Email channel enabled for the application
* Permission to create mail templates and transactional messages in the panel
* The email address of the recipient
* The files to attach, 10 MB or less in total together with the email

## Step 1: Create the Mail Template with Placeholders

Create a mail template in the Netmera panel. Add a placeholder for every value that changes per send, written in the `{{NAME}}` format. Placeholders can be used in the mail subject, the mail preheader, and the body.

In the example below, the mail subject and preheader are `Your document is ready – {{DATE}}` and the body is `Your document dated {{DATE}} is attached.`. All three use one placeholder named `DATE`.

<figure><img src="https://2578508252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0bOAscrXzPSujyzq8DEz%2Fuploads%2FXjXTNTpDaIUoP27uEUo8%2Fimage.png?alt=media&amp;token=3cf14c26-4f2c-4a22-a438-45d1a0dc0c88" alt="Mail template with the {{DATE}} placeholder in the mail subject, mail preheader, and body"><figcaption><p>Mail template with the {{DATE}} placeholder in the mail subject, mail preheader, and body</p></figcaption></figure>

{% hint style="info" %}
Placeholder names are case-sensitive. A placeholder written as `{{DATE}}` is filled only by a field named `DATE`, not by `date` or `Date`.
{% endhint %}

**Expected result:** A saved mail template that contains the placeholders.

## Step 2: Create the Transactional Message and Note the Message Key

1. In the panel, go to **Transactional Messages** and select **Create Transactional Message**.
2. In the **Setup** step, choose **E-Mail** as the campaign type.
3. In the **What** step, select the mail template created in Step 1 under **Mail Template**. The mail subject, preheader, and body of the template are loaded into the message.<br>

   <figure><img src="https://2578508252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0bOAscrXzPSujyzq8DEz%2Fuploads%2FlDMWnEI1vmfr2OdbV5bn%2Fimage.png?alt=media&amp;token=a79830ef-5734-4600-bf7e-2202fa68d891" alt=""><figcaption><p>What step of a transactional email with the "Your document is ready" mail template selecte</p></figcaption></figure>
4. In the **API & Config** step, note the **Message Key**. This value is sent as `notificationKey` in the API request. In the example, the Message Key is `12345`.<br>

   <figure><img src="https://2578508252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0bOAscrXzPSujyzq8DEz%2Fuploads%2FhdHfLwhWw95l5i8IBLY8%2Fimage.png?alt=media&amp;token=a706eb49-6e26-4afd-8729-5698f712778e" alt=""><figcaption><p>API &#x26; Config step showing the Message Key of the transactional email</p></figcaption></figure>
5. Complete the **GO!** step to save and activate the message.

**Expected result:** An active transactional email and its Message Key.

## Step 3: Send the Email with Attachments and Parameters

Call `sendEmailWithAttachment` as a `multipart/form-data` request. Send each template parameter as a separate form field whose name matches the placeholder, written without the `{{}}` characters.

```bash
curl https://restapi.netmera.com/rest/3.0/sendEmailWithAttachment \
  --request POST \
  --header 'X-netmera-api-key: <API_KEY>' \
  --form 'mailAttachment=@"/path/to/document.pdf"' \
  --form 'to="user@example.com"' \
  --form 'notificationKey="12345"' \
  --form 'DATE="27.10.2026"'
```

| Field                                | Type | Description                                                        |
| ------------------------------------ | ---- | ------------------------------------------------------------------ |
| `mailAttachment`                     | File | The file to attach. Repeat the field to attach more than one file. |
| `to`                                 | Text | The email address of the recipient.                                |
| `notificationKey`                    | Text | The Message Key noted in Step 2.                                   |
| Placeholder name, for example `DATE` | Text | The value of the placeholder. Add one field per placeholder.       |

To attach several files and fill several placeholders, repeat the fields:

```bash
curl https://restapi.netmera.com/rest/3.0/sendEmailWithAttachment \
  --request POST \
  --header 'X-netmera-api-key: <API_KEY>' \
  --form 'mailAttachment=@"/path/to/invoice.pdf"' \
  --form 'mailAttachment=@"/path/to/summary.xlsx"' \
  --form 'to="user@example.com"' \
  --form 'notificationKey="12345"' \
  --form 'DATE="27.10.2026"' \
  --form 'NAME="Alex"'
```

{% hint style="warning" %}
Parameters are sent as individual form fields. A `params` field that holds a JSON object, as used in `sendNotification`, is not applied by this service, and the placeholder stays unchanged in the delivered email.
{% endhint %}

{% hint style="warning" %}
Do not set the `Content-Type` header manually. A multipart request needs a boundary value in this header, and HTTP clients such as curl and Postman add it automatically. A manually written `Content-Type: multipart/form-data` header without a boundary can make the request unreadable.
{% endhint %}

{% hint style="info" %}
The email size and the total size of the attachments must not exceed 10 MB. Supported file types include `png`, `jpg`, `jpeg`, `gif`, `pdf`, `csv`, `txt`, `xls`, `xlsx`, `mp4`, `mpeg`, and `avi`.
{% endhint %}

**Expected result:** The service returns HTTP `200 OK` with an empty `{}` body.

## Step 4: Check the Delivered Email

Open the inbox of the recipient. With the first request in Step 3, the email arrives with the subject `Your document is ready – 27.10.2026`, the body `Your document dated 27.10.2026 is attached.`, and `document.pdf` as the attachment.

<figure><img src="https://2578508252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0bOAscrXzPSujyzq8DEz%2Fuploads%2FLz2b0Ph355X0E3vl8XmX%2Fimage.png?alt=media&amp;token=d6180ded-f5c5-4b43-911b-8364f9bb5d58" alt=""><figcaption><p>Delivered email in the inbox list with the date filled in and document.pdf attached</p></figcaption></figure>

<figure><img src="https://2578508252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0bOAscrXzPSujyzq8DEz%2Fuploads%2F7yVwo8rncguZg7y4IHBO%2Fimage.png?alt=media&amp;token=58f58302-5257-49b8-8db6-58d767646448" alt=""><figcaption><p>Delivered email with the date filled in the subject and body, and document.pdf attached</p></figcaption></figure>

**Expected result:** The email arrives with the filled values and the attachments.

## Step 5: Track the Results

The response of `sendEmailWithAttachment` is empty, so use the Message Key to find the results. Every email sent with the same Message Key is reported under the same transactional email in the panel. A separate report is not created for each send.

To read the result of each email through the API, call `getPushResult` with the Message Key. Each entry has `"platform": "EMAIL"` and a `status` of `SUCCESS` or `FAILED`. A failed entry also carries an `errorCode` and an `errorMsg`.

```bash
curl 'https://restapi.netmera.com/rest/3.0/getPushResult?notificationKey=12345&max=10' \
  --header 'X-netmera-api-key: <API_KEY>'
```

{% hint style="info" %}
`getPushStats` does not return statistics for email notification keys. Read the per-email results with `getPushResult`, and the totals from the report of the transactional email in the panel.
{% endhint %}

In the panel, open the transactional email under **Transactional Messages** to see its report: delivered, opened, clicked, bounced, and unsubscribed counts. The **User Activity** section of the report lists the activity of each recipient by email address.

**Expected result:** One `getPushResult` entry per email, and the totals in the panel report of the transactional email.

## Troubleshooting

| Symptom                                         | Likely cause                                                                                       | Solution                                                                                                           |
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| The email shows `{{DATE}}` unchanged            | The field name does not match the placeholder, or the value was sent inside a JSON field           | Send the value as a separate form field. Check that the field name matches the placeholder, including letter case. |
| `400 Bad Request` with `Failed to read request` | The request was sent to a service that expects JSON, or the `Content-Type` header was set manually | Check that the URL ends with `sendEmailWithAttachment`. Remove any manually set `Content-Type` header.             |
| The email does not arrive                       | The recipient is not a Netmera user, or the API key belongs to another application                 | Complete Step 2. Check that the API key belongs to the application in which the transactional message was created. |
| The email is not sent                           | The total size or a file type is not supported                                                     | Keep the email and the attachments within 10 MB and use a supported file type.                                     |
| `getPushResult` returns an entry with `FAILED`  | The email could not be delivered                                                                   | Read the `errorCode` and `errorMsg` of the entry to find the reason.                                               |

## Verification Checklist

* The mail template uses the `{{NAME}}` format for every placeholder
* The `notificationKey` is the Message Key of an active transactional email
* The request is sent as `multipart/form-data` without a manually set `Content-Type` header
* Every placeholder has a form field with the same name
* The email and its attachments together stay within 10 MB

## Related Pages

For the request formats of the email services, see the Email section of the [Notifications](https://user.netmera.com/netmera-developer-guide/api-documentation/rest-api/notifications.md) page. For authentication and request headers, see [Setup](https://user.netmera.com/netmera-developer-guide/api-documentation/rest-api/setup.md). To send an email without attachments, see [Sending a Transactional Email to a Single User](https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-transactional-email.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://user.netmera.com/netmera-developer-guide/api-documentation/recipes/sending-a-transactional-email-with-attachments-and-parameters.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
