# MailList

### Summary

* Lists emails with optional filters, sorting, and paging. Ideal for inbox or work‑queue views.

### Graph Endpoint

* `GET /me/messages`
* Folder‑scoped: `GET /me/mailFolders/{folder}/messages`

### Parameters

#### Optional

* `select: string[]` — Fields to include.
* `filter: Array` — Simple conditions, e.g. `{ field, op, value }` or `{ fn, field, value }`.
* `orderBy: Array<{ field: string, dir: 'asc'|'desc' }>`
* `top: number` — 1..100
* `count: boolean` — include a result count
* `folder: string` — Folder id or well‑known name (e.g., `Inbox`, `Archive`).

### Presets (optional)

* Shortcuts for common list scenarios.
* See: [Mail Presets](https://gebra-it.gitbook.io/wiki/client-api-reference/functions/businessfunction/graph-api/mail/mail-presets) for all available presets and examples.

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'List',
  parameters: {
    preset: 'LastNDays',
    presetValue: 7,
    top: 50
  }
})
```

### Usage (app.businessFunction)

#### Minimal

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'List',
  parameters: {
    top: 25
  }
})
```

#### With filters and sorting

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'List',
  parameters: {
    folder: 'Inbox',
    select: ['id','subject','from','receivedDateTime','isRead','webLink'],
    filter: [
      { field: 'isRead', op: 'eq', value: false },
      { fn: 'contains', field: 'subject', value: 'invoice' }
    ],
    orderBy: [ { field: 'receivedDateTime', dir: 'desc' } ],
    top: 50,
    count: true
  }
})
```

### Response

```json
{
  "items": [
    {
      "id": "AAMkAGI2N...",
      "subject": "Invoice April",
      "from": { "name": "Contoso Billing", "address": "billing@contoso.com" },
      "receivedDateTime": "2024-09-23T14:22:17Z",
      "isRead": false,
      "webLink": "https://outlook.office.com/..."
    }
  ],
  "nextLink": "...",
  "count": 128
}
```
