# Create Email Message — Selzy

> Adds a new email message. See the documentation

- Key: `selzy-create-email-message`
- Type: Action (Write)
- Version: 0.0.3
- App: Selzy (`selzy`) — https://pipedream.com/apps/selzy.md
- This page (HTML): https://pipedream.com/apps/selzy/actions/create-email-message
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/selzy/actions/create-email-message/create-email-message.mjs

## Description

Adds a new email message. [See the documentation](https://selzy.com/en/support/category/api/messages/)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `senderName` | `string` | Yes | It is a string that does not match the email address (the sender_email argument). |
| `senderEmail` | `string` | Yes | This email must be checked (to do this, you need to manually create at least one email with this return address via the web interface, then click on the "send the confirmation request" link and follow the link from the email). |
| `subject` | `string` | Yes | String with the letter subject. It may include substitution fields. If you wish to use substitution fields, specify a string within a Pipedream Custom Expression and escape the curly brackets with a backslash. For example: {{ "Welcome to Our Newsletter, \{\{Name\}\}!" }}. The parameter is optional if Template Id is indicated. |
| `body` | `string` | Yes | HTML body of the letter. It may include substitution fields. If you wish to use substitution fields, specify an HTML string within a Pipedream Custom Expression and escape the curly brackets with a backslash. For example: {{ "<p>Hello \{\{Name\}\},</p><p>Here is your update.</p>" }}. |
| `listId` | `string` | Yes | Code of the list on which the mailing will be sent. Options are loaded from the connected account. |
| `textBody` | `string` | No | Text body of the letter. It may include substitution fields. If you wish to use substitution fields, specify a text string within a Pipedream Custom Expression and escape the curly brackets with a backslash. For example: {{ "Hello \{\{Name\}\},\nHere is your update." }}. |
| `generateText` | `boolean` | Yes | True means that the text part of the letter will be generated automatically based on the HTML part. If you do not provide the text version along with the HTML version, you are recommended to set the Generate Text parameter to true for automatic generation of the text part of the letter. If the text variant of the letter is provided using the Text Body parameter, the Generate Text parameter is ignored. Thus, if the Generate Text value has been set to true, the server's response will contain a warning. |
| `rawBody` | `string` | No | It is intended to save the json structure of the block editor data structure (if the value is Message Format = block) The parameter obtains only the JSON structure, otherwise it will not be transferred. |
| `messageFormat` | `string` | No | It defines the manner of creating a letter. 1 - If you transfer the text value in this parameter and both the body and Text Body parameters are filled, the body parameter will be ignored, and the letter will be created from the data, transferred in the Text Body parameter. 2 - If you transfer the block value in this parameter but do not specify Raw Body, the letter will be saved as Raw HTML. 3 - If you transfer the block value in this parameter, the body and Raw Body parameters must be transferred so taht you can save the message in the block editor format. |
| `lang` | `string` | No | Two-letter language code for the string with the unsubscribe link that is added to each letter automatically. If it is not specified, the language code from the API URL is used. In addition to the string with the unsubscribe link, this language also affects the interface of the unsubscribe page. Languages en, it, ua and ru are fully supported, and in case of some other languages (da, de, es, fr, nl, pl, pt, tr), the string with a link will be translated, and the control interface will be in English. |
| `templateId` | `string` | No | ID of the user letter template created before, on the basis of which a letter can be created. If you have transferred this parameter, you may skip the mandatory Subject, Body, as well as Text Body and Lang parameters. These values will be taken from the corresponding parameters of the template the id of which was specified. If any of the above parameters is still transferred, the system will ignore the parameter that is taken from the template parameters, and the parameter explicitly transferred in this method will be used. Options are loaded from the connected account. |
| `systemTemplateId` | `string` | No | ID of the system letter template created before, on the basis of which a letter can be created. If you have transferred this parameter, you may skip the mandatory Subject, Body, as well as Text Body and Lang parameters. These values will be taken from the corresponding parameters of the template the id of which was specified. If any of the above parameters is still transferred, the system will ignore the parameter that is taken from the template parameters, and the parameter explicitly transferred in this method will be used. If none of the Template Id or System Template Id parameters is specified, templates will not be used to create the letter. Options are loaded from the connected account. |
| `wrapType` | `string` | No | Alignment of the message text on the specified side. If the argument is missing, the text will not be aligned. |
| `categories` | `string[]` | No | A list of letter categories. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "selzy",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "selzy-create-email-message",
  arguments: {
    senderName: "Sender's name",
    senderEmail: "Sender's email address",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "selzy-create-email-message",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    selzy: { authProvisionId: "apn_xxxxxxx" },
    senderName: "Sender's name",
    senderEmail: "Sender's email address",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "selzy-create-email-message",
    "configured_props": {
      "selzy": { "authProvisionId": "apn_xxxxxxx" },
      "senderName": "Sender'\''s name",
      "senderEmail": "Sender'\''s email address"
    }
  }'
```

---

- App: https://pipedream.com/apps/selzy.md · All apps: https://pipedream.com/apps
