# Send Email with Dataset Attachments — CSV, Excel, SMTP (`saliga/send-email-dataset-attachments`) Actor

E-mail Apify results as CSV, Excel or JSON attachments with an HTML table in the body, or send any notification, through your own SMTP (Gmail, Outlook, Zoho, SES) or Resend. Use it after any scraper. $0.005 per e-mail.

- **URL**: https://apify.com/saliga/send-email-dataset-attachments.md
- **Developed by:** [Salih Küçükkayış](https://apify.com/saliga) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 e-mail sents

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

E-mail the **results of any Apify run** as **CSV, Excel or JSON attachments**, with the first rows as a readable **HTML table** in the body. Or send any notification. It goes through **your own mail server** (Gmail, Outlook / Microsoft 365, Zoho, Amazon SES, any SMTP) or **Resend**, so it arrives from your address. Made to run after a scraper: daily lead lists, price changes, new jobs, monitoring reports.

**$0.005 per e-mail.** Preview runs and skipped empty reports are free. No subscription.

### Quick start

Press **Start** with the example input: it builds a preview (no mail server given, so nothing is sent) and saves it as `PREVIEW.html`.

To send the results of a scraper with Gmail:

```json
{
  "to": "team@yourcompany.com",
  "subject": "{{rowCount}} new leads today",
  "text": "Today's new leads are attached.",
  "datasetId": "DATASET_ID_OF_THE_RUN",
  "attachmentFormats": ["xlsx"],
  "skipIfEmpty": true,
  "smtpHost": "smtp.gmail.com",
  "smtpUser": "you@gmail.com",
  "smtpPassword": "your app password"
}
```

### Use it after a scraper

On the scraper's page: **Integrations → Connect Actor or Task → Send Email with Dataset Attachments**, and map the run's default dataset ID to **Dataset to send**. Turn on **Don't send when the dataset is empty** for monitors that only report new results.

### What the e-mail contains

- Your text or HTML, with `{{rowCount}}` and `{{datasetId}}` filled in (also in the subject).
- A table of the first rows (50 by default, up to 15 columns); links are clickable.
- Attachments: **CSV** (UTF-8, opens correctly in Excel), **Excel (.xlsx)** and/or **JSON**. Nested fields become columns like `address/city`. Text that looks like a formula is written as text, so a scraped cell can never run a formula.
- Choose **Columns** to send only the fields that matter, in your order.

### Sending: SMTP or Resend

| Provider | SMTP server | Port | Password |
|---|---|---|---|
| Gmail | smtp.gmail.com | 465 | An [app password](https://myaccount.google.com/apppasswords) (needs 2-step verification) |
| Outlook / Microsoft 365 | smtp.office365.com | 587 | Your password or an app password, if SMTP is enabled for the mailbox |
| Zoho Mail | smtp.zoho.com | 465 | An app-specific password |
| Amazon SES | email-smtp.REGION.amazonaws.com | 587 | SES SMTP credentials |

Or create an API key at [Resend](https://resend.com) for a verified domain and put it in **Resend API key**.

Passwords and keys are stored encrypted by Apify and are only used to log in to your mail server.

### Switching from apify/send-mail

The fields `to`, `cc`, `bcc`, `subject`, `text`, `html`, `replyTo` and `isMock` work the same. Add your SMTP server (or a Resend key) and, if you like, a dataset to attach.

### Output

The run's dataset and the `OUTPUT` record say whether the server accepted the e-mail, the recipients, the subject, the number of rows and the attachment names.

### Limits and good to know

- At most **50 recipients per run** and **20 MB of attachments**. This Actor is for reports and notifications to people who expect them, not for newsletters or cold e-mail.
- "Accepted" means your mail server took the e-mail; delivery and spam filtering are up to the receiving server. Sending from your own domain with SPF and DKIM set up gives the best delivery.
- Up to 200,000 dataset rows are read; for bigger datasets send a link to the dataset instead.

### More from this developer

- [Google Sheets Import & Export](https://apify.com/saliga/google-sheets-import-export): send results to a Google Sheet instead, with upsert by key.
- [Dataset Merge & Dedup Datasets](https://apify.com/saliga/dataset-merge-dedupe): merge, clean and dedupe results before sending them.

Questions or a missing feature: open an issue on the Actor page.

**Need a custom version?** I also build custom Actors, changes to this one, and n8n or Make integrations around them, for a fixed price. Open an issue on the Actor page starting with "Custom request", or email support@saligasoftware.com, with what you need and an example input.

# Actor input Schema

## `to` (type: `string`):

Recipients, comma separated. At most 50 recipients in total (to, cc, bcc).

## `cc` (type: `string`):

Copy recipients, comma separated.

## `bcc` (type: `string`):

Hidden copy recipients, comma separated.

## `subject` (type: `string`):

{{rowCount}} is replaced by the number of dataset rows, e.g. "{{rowCount}} new leads today".

## `text` (type: `string`):

Plain-text body.

## `html` (type: `string`):

Optional HTML body. With a dataset, the results table is added below it.

## `replyTo` (type: `string`):

Address replies go to, if not the sender.

## `datasetId` (type: `string`):

The results to send, e.g. the default dataset of a scraper run. In an integration, map the dataset ID of the run here.

## `attachmentFormats` (type: `array`):

Nested fields become columns like address/city.

## `attachmentName` (type: `string`):

File name of the attachments, without extension.

## `includeTable` (type: `boolean`):

The first rows as an HTML table (up to 15 columns).

## `tableMaxRows` (type: `integer`):

How many rows the table in the body shows (the attachments always have all rows).

## `columns` (type: `array`):

Only these columns, in this order (attachments and table). Empty: all.

## `skipIfEmpty` (type: `boolean`):

Handy for daily monitors: no new results, no e-mail (and no charge).

## `from` (type: `string`):

The sender. Must be allowed by your mail server (for Gmail: your own address). Empty: the SMTP user.

## `fromName` (type: `string`):

Sender name shown in the inbox, e.g. Lead Bot.

## `smtpHost` (type: `string`):

Gmail: smtp.gmail.com · Outlook/Microsoft 365: smtp.office365.com · Zoho: smtp.zoho.com · Amazon SES: email-smtp.<region>.amazonaws.com

## `smtpPort` (type: `integer`):

465 (SSL) or 587 (STARTTLS). Empty: 465.

## `smtpSecurity` (type: `string`):

Empty: chosen from the port.

## `smtpUser` (type: `string`):

Usually your full e-mail address.

## `smtpPassword` (type: `string`):

For Gmail and Outlook an app password (see the README). Stored encrypted.

## `resendApiKey` (type: `string`):

Instead of SMTP: send through Resend (resend.com) with a verified domain.

## `isMock` (type: `boolean`):

Build the e-mail and save it as PREVIEW.html without sending. Also used when no SMTP server or Resend key is given.

## Actor input object example

```json
{
  "to": "you@example.com",
  "subject": "{{rowCount}} new results",
  "text": "Here are the latest results.",
  "attachmentFormats": [
    "csv"
  ],
  "attachmentName": "results",
  "includeTable": true,
  "tableMaxRows": 50,
  "skipIfEmpty": false,
  "isMock": false
}
```

# Actor output Schema

## `summary` (type: `string`):

Whether the e-mail was sent, recipients, subject, attachments.

## `preview` (type: `string`):

The e-mail body, in preview mode.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "to": "you@example.com",
    "subject": "{{rowCount}} new results",
    "text": "Here are the latest results."
};

// Run the Actor and wait for it to finish
const run = await client.actor("saliga/send-email-dataset-attachments").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "to": "you@example.com",
    "subject": "{{rowCount}} new results",
    "text": "Here are the latest results.",
}

# Run the Actor and wait for it to finish
run = client.actor("saliga/send-email-dataset-attachments").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "to": "you@example.com",
  "subject": "{{rowCount}} new results",
  "text": "Here are the latest results."
}' |
apify call saliga/send-email-dataset-attachments --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,saliga/send-email-dataset-attachments"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/qXl2UaKhPf4VKXY3N/builds/RixycPhY92KFnMwhO/openapi.json
