# MailDelta

### Summary

* Tracks message changes efficiently (new/updated/deleted) using delta queries. Useful for sync and polling scenarios.

### Graph Endpoint

* Recommended (folder‑scoped): `GET /me/mailFolders/{id}/messages/delta`
* Root (may be unsupported in some tenants): `GET /me/messages/delta`
* Continue: call the returned `nextLink` or `deltaLink`

See also: MailFolderList — to discover folder IDs.

### Parameters

#### Optional

* `select: string[]`
* `top: number` — 1..100
* `folder: string` — Folder id or well‑known name
* `nextLink: string` — Continuation link
* `deltaLink: string` — Use to resume from last sync state

### Usage (app.businessFunction)

#### Initial sync

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'Delta',
  parameters: {
    folder: 'inbox',
    select: ['id','subject','from','receivedDateTime','isRead','webLink'],
    top: 50
  }
})
```

#### Continue with nextLink / deltaLink

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'Delta',
  parameters: {
    nextLink: 'https://graph.microsoft.com/...',
    // or deltaLink: 'https://graph.microsoft.com/...'
  }
})
```

### Response

```json
{
  "items": [
    { "id": "...", "subject": "...", "isRead": false },
    { "id": "...", "removed": true, "removedReason": "deleted" }
  ],
  "nextLink": "...",
  "deltaLink": "..."
}
```

### Notes

* In some tenants or configurations, calling delta at the root messages level (`/me/messages/delta`) can return an error like: “Unsupported request: Change tracking is not supported against 'microsoft.graph.message'.”
* Prefer folder‑scoped delta by specifying `folder` (e.g., `'Inbox'` or a folder id). Use MailFolderList to discover folder IDs.
