# Microsoft Outlook

The Microsoft Outlook integration empowers you to fully manage your communication and schedule within Dapta. It combines powerful Email automation with advanced Calendar management, featuring the inte

### 🚀 Key Capabilities

#### 📧 Email

* **Send Emails**: Automate the sending of rich HTML emails to multiple recipients.
* **Manage Attachments**: (Coming Soon) Automatically handle file attachments.

#### 📅 Calendar

* **Smart Scheduling**: Locate free time slots based on your working hours using the **Get Availability** operation.
* **Manage Events**: Create, update, list, and delete meetings effortlessly.
* **Timezone Aware**: Automatically handles complex global timezone conversions.
* **Online Meetings**: Generate Microsoft Teams links with a single toggle.

***

### ⚙️ Prerequisites

To use this integration, you need:

1. A **Microsoft 365** account (Business or Personal).
2. *Optional*: An active **Outlook Mailbox** (only required if you plan to use the **Send Email** operations).

***

### 🔐 Authentication

Dapta uses secure **OAuth 2.0** authentication to connect to your Microsoft account. We never see or store your password.

#### Required Permissions

Upon connection, you will be prompted to grant the following permissions:

* `Calendars.ReadWrite`: To manage your events and verify availability.
* `Mail.Send`: To send automated emails on your behalf.
* `User.Read`: To identify your profile and timezone settings.

#### Connection Steps

**Option 1: Quick Connect (Recommended)**

1. Add the **Microsoft Outlook** node to your flow canvas.
2. Locate the **Credential** dropdown in the configuration panel.
3. Click the **+ (Plus)** button next to the dropdown.
4. Follow the Microsoft login prompt to authorize access.
5. Your credential will be automatically saved and selected.

**Option 2: Settings Menu**

1. Navigate to the [**Credentials Page**](https://app.dapta.ai/settings/oauth) in your Dapta dashboard.
2. Click **Add Credential** and select **Microsoft Outlook**.
3. Click **Connect** and sign in with your **Microsoft 365 account**.
4. Review the requested permissions and click **Yes/Accept**.

***

### 🛠️ Calendar Operations

#### 1. Get Availability

This feature scans your calendar and returns a list of "free" time slots, strictly respecting your working hours and existing meetings.

**Parameters**

* **Calendar ID** *(String, Optional)* The ID of the calendar to check. Defaults to your primary calendar.
* **From Date** *(Date, Required)* Start date for the availability search (Format: `YYYY-MM-DD`, e.g., `2024-01-01`).
* **To Date** *(Date, Required)* End date for the availability search (Format: `YYYY-MM-DD`).
* **Start Time** *(String, Optional)* Working hours start time (e.g., `09:00`). Default: `08:00`.
* **End Time** *(String, Optional)* Working hours end time (e.g., `17:00`).
* **Slot Duration** *(Number, Optional)* Length of each time slot in minutes (e.g., `30`).
* **Buffer Time** *(Number, Optional)* Buffer minutes to leave empty between meetings (e.g., `15`).
* **Exclude Weekends** *(Boolean, Optional)* If `true`, Saturdays and Sundays are excluded from availability.
* **Timezone** *(String, Optional)* The timezone for the calculation (e.g., `America/New_York`).

**Response Example**

```json
{
  "success": true,
  "date_range": { "from": "2024-01-01", "to": "2024-01-02" },
  "slots": {
    "2024-01-01": [
      { "start": "09:00", "end": "09:30" },
      { "start": "09:30", "end": "10:00" }
    ]
  },
  "summary": { "total_slots": 5, "first_available": "2024-01-01T09:00:00" }
}
```

***

#### 2. List Calendars

Retrieve a list of all calendars associated with your account.

**Response Example**

```json
{
  "value": [
    {
      "id": "AAMkAGI...",
      "name": "Calendar",
      "color": "auto",
      "changeKey": "..."
    }
  ]
}
```

***

#### 3. Get Calendar

Retrieve detailed information about a specific calendar.

**Parameters**

* **Calendar ID** *(String, Required)* The unique identifier of the calendar.

**Response Example**

```json
{
  "success": true,
  "calendar": {
    "id": "AAMkAGI...",
    "name": "Work",
    "canEdit": true
  }
}
```

***

#### 4. List Events

Fetch upcoming meetings within a specific date range.

**Parameters**

* **From Date** *(Date, Required)* Start of the date range.
* **To Date** *(Date, Required)* End of the date range.
* **Timezone** *(String, Optional)* If provided, converts all event times to this timezone in the output.

**Response Example**

```json
{
  "success": true,
  "events": [
    {
      "id": "AAMkAGI...",
      "subject": "Team Sync",
      "start": { "dateTime": "2024-01-01T10:00:00", "timeZone": "UTC" },
      "end": { "dateTime": "2024-01-01T11:00:00", "timeZone": "UTC" }
    }
  ]
}
```

***

#### 5. Get Event

Retrieve details of a single event using its ID.

**Parameters**

* **Event ID** *(String, Required)* The unique identifier of the event.

**Response Example**

```json
{
  "success": true,
  "event": {
    "id": "AAMkAGI...",
    "subject": "Lunch",
    "location": { "displayName": "Cafeteria" }
  }
}
```

***

#### 6. Create Event

Schedule a new meeting on your calendar.

**Parameters**

* **Title** *(String, Required)* The subject of the event.
* **Start Date/Time** *(Date, Required)* When the event begins. **Must be in ISO 8601 format** (e.g., `2024-12-31T14:30:00`).
* **End Date/Time** *(Date, Required)* When the event ends. **Must be in ISO 8601 format** (e.g., `2024-12-31T15:30:00`).
* **Attendees** *(List, Optional)* Comma-separated email addresses (e.g., `bob@test.com, alice@test.com`).
* **Online Meeting** *(Boolean, Optional)* If `true`, automatically adds a Microsoft Teams link to the event.
* **Description** *(String, Optional)* Details or agenda for the event body.
* **Location** *(String, Optional)* Physical location or room name.
* **Reminder Minutes** *(Number, Optional)* Minutes before the event to show a notification.
* **Timezone** *(String, Optional)* Specific timezone for the provided start/end times.

**Response Example**

```json
{
  "success": true,
  "event": {
    "id": "AAMkAGI...",
    "subject": "Project Kickoff",
    "webLink": "https://outlook.office365.com/..."
  }
}
```

***

#### 7. Update Event

Modify details of an existing event.

**Parameters**

* **Event ID** *(String, Required)* The unique identifier of the event to update.
* **Title** *(String, Optional)* New subject for the event.
* **Start Date/Time** *(Date, Optional)* New start time (ISO 8601).
* **End Date/Time** *(Date, Optional)* New end time (ISO 8601).
* **Description** *(String, Optional)* New description.
* **Location** *(String, Optional)* New location.

***

#### 8. Delete Event

Remove an event from the calendar.

**Parameters**

* **Event ID** *(String, Required)* The unique identifier of the event to delete.

**Response Example**

```json
{
  "success": true,
  "message": "Event deleted successfully",
  "event_id": "AAMkAGI..."
}
```

***

### 📧 Email Operations

#### 9. Send Email

Send automated emails directly from your Outlook account.

**Parameters**

* **To** *(List, Required)* Recipients (comma separated).
* **Subject** *(String, Required)* Email subject line.
* **Body Format** *(Dropdown, Required)* Choose between `Text` or `HTML`.
* **Body / HTML** *(String, Required)* The content of the email.
* **CC / BCC** *(List, Optional)* Optional copy recipients.

**Response Example**

```json
{
  "success": true,
  "message": "Email sent successfully"
}
```

***

### 🚧 Usage Limits & Quotas

Microsoft imposes usage limits on the API to prevent abuse.

* **Email Sending**: Limits vary by account type (e.g., \~10,000 recipients/day for Business accounts).
* **Rate Limits**: Excessive requests in a short time may result in `429 Too Many Requests`.
* **Tip**: If you are sending emails in a loop, add a **Wait** node (e.g., 1-2 seconds) inside the loop to ensure smooth delivery.

***

### ❓ Troubleshooting

| Issue                       | Cause        | Solution                                                                   |
| --------------------------- | ------------ | -------------------------------------------------------------------------- |
| **"Invalid Timezone"**      | Typo         | Use standard IANA names like `America/New_York` or `Europe/London`.        |
| **"Time Range Too Big"**    | API Limit    | Keep `List Events` range under 31 days for best performance.               |
| **"Access Denied"**         | Permissions  | Reconnect your credential and ensure you accept all requested permissions. |
| **Events shows wrong time** | UTC vs Local | Check the `Timezone` parameter. If empty, Dapta often defaults to UTC.     |
