APM

>Agent Skill

@microsoft/send-email

skilldata

Send HTML email notifications via Azure Logic App. Use when (1) sending formatted emails to recipients, (2) delivering reports or summaries via email, (3) triggering email notifications from workflows. Triggers on requests like "send email", "email this", "send via email", "mail to".

gitapi-design
apm::install
$apm install @microsoft/send-email
apm::skill.md
---
name: send-email
description: Send HTML email notifications via Azure Logic App. Use when (1) sending formatted emails to recipients, (2) delivering reports or summaries via email, (3) triggering email notifications from workflows. Triggers on requests like "send email", "email this", "send via email", "mail to".
---

# Send Email Skill

Send HTML email notifications to specified recipients via an Azure Logic App HTTP trigger.

## Overview

This skill constructs a well-formatted HTML email from user-provided content and posts it to a configured Logic App endpoint for delivery.

## Usage

### Required Environment Variable

The mailing URL must be set via environment variable:
- `MAILING_URL`: The Azure Logic App HTTP trigger URL for email sending

### Required Input from User

The user must provide:
1. **Content**: The information/message to be sent (any format - text, data, structured content)
2. **Recipients**: One or more email addresses
3. **Title** (optional): Subject line for the email
4. **Time frame** (optional): Relevant date/period context

### Payload Schema

The skill constructs and sends a JSON payload:

```json
{
  "title": "Email Subject",
  "timeFrame": "January 28, 2026",
  "body": "<html><body>...</body></html>",
  "workflowRunUrl": "https://github.com/org/repo/actions/runs/12345",
  "recipients": ["user1@example.com", "user2@example.com"]
}
```

For the full JSON schema, see [references/payload-schema.json](references/payload-schema.json).

### HTML Body Construction

The skill must transform user-provided content into well-formatted HTML:

1. **Use semantic HTML structure with inline CSS** (email clients don't support external stylesheets)

2. **Base template**:
   ```html
   <html>
   <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 800px; margin: 0 auto; padding: 20px;">
     <div style="background: #f6f8fa; padding: 20px; border-radius: 8px; margin-bottom: 20px;">
       <h1 style="color: #0366d6; margin: 0;">{{title}}</h1>
       <p style="color: #586069; margin: 5px 0 0 0;">{{timeFrame}}</p>
     </div>
     
     <!-- Main content goes here - format based on user input -->
     {{content}}
     
     <hr style="border: none; border-top: 1px solid #e1e4e8; margin: 20px 0;">
     <p style="color: #586069; font-size: 12px;">
       Generated by <a href="{{workflowRunUrl}}" style="color: #0366d6;">GitHub Actions workflow</a>
     </p>
   </body>
   </html>
   ```

3. **Content formatting guidelines**:
   - Plain text → Wrap in `<p>` tags
   - Lists → Use `<ul>` or `<ol>` with appropriate styling
   - Tables/data → Use `<table>` with borders and padding
   - Links → Use `<a>` tags with `color: #0366d6`
   - Emphasis → Use `<strong>` or styled `<span>` elements
   - Code → Use `<code>` with monospace font and background

## Workflow

1. Receive content and recipients from user
2. Validate that `MAILING_URL` environment variable is set
3. Validate that recipients list is not empty
4. Construct HTML body from the user-provided content
5. POST the JSON payload to the Logic App endpoint
6. Report success or failure to the user

## Example Commands

- "Send this to user@example.com via email"
- "Email the following summary to the team"
- "Mail this information to john@company.com"
- "Send an email with these details"

## Implementation

Use curl or equivalent HTTP client to POST the JSON:

```bash
curl -X POST "$MAILING_URL" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Email Subject",
    "timeFrame": "January 28, 2026",
    "body": "<html><body>...</body></html>",
    "workflowRunUrl": "https://github.com/org/repo/actions/runs/12345",
    "recipients": ["user@example.com"]
  }'
```

## Response Handling

- **HTTP 2xx**: Email sent successfully ✅
- **HTTP 4xx/5xx**: Failed to send email ❌

Report the result to the user with the HTTP status code.