# MailAttachmentAdd

### Summary

* Adds a small file attachment to an existing message (draft or sent).

### Graph Endpoint

* `POST /me/messages/{messageId}/attachments`

### Parameters

#### Required

* `messageId: string` — Alias: `id`
* One of:
  * `attachmentIds: number[]` — Up to 10 repository attachment IDs; backend fetches file data and uploads it.
  * `name: string` and `contentBytesBase64: string` — Direct upload of a single file (alias: `contentBase64`).

#### Optional

* `contentType: string` — Default `application/octet-stream`

### Usage (app.businessFunction)

#### Using repository attachments (recommended)

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'AttachmentAdd',
  parameters: {
    messageId: 'AAMkAGI2N...',
    attachmentIds: [1012, 1013] // up to 10
  }
})
```

#### Single file (base64)

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'AttachmentAdd',
  parameters: {
    messageId: 'AAMkAGI2N...',
    name: 'report.pdf',
    contentBytesBase64: 'JVBERi0xLjQKJc...'
  }
})
```

### Response

```json
// When using attachmentIds
{ "ok": true, "attachments": [ { "id": "...", "name": "..", "size": 123456, "contentType": "application/pdf" } ] }

// When uploading a single base64 file
{ "ok": true, "attachment": { "id": "...", "name": "report.pdf", "size": 123456, "contentType": "application/pdf" } }
```

### Notes

* Backend uploads via upload sessions (robust for any size). Limit: max 10 attachments per call when using `attachmentIds`.
* For external clients without repository attachments, use the base64 single-file option or `MailAttachmentUploadLarge`.

#### See also

* [MailSend](https://gebra-it.gitbook.io/wiki/client-api-reference/functions/businessfunction/graph-api/mail/mailsend) — send a new message with `attachmentIds` in one call
* [MailReply](https://gebra-it.gitbook.io/wiki/client-api-reference/functions/businessfunction/graph-api/mail/mailreply) — reply and attach repository files
* [MailReplyAll](https://gebra-it.gitbook.io/wiki/client-api-reference/functions/businessfunction/graph-api/mail/mailreplyall) — reply-all with attachments
* [MailForward](https://gebra-it.gitbook.io/wiki/client-api-reference/functions/businessfunction/graph-api/mail/mailforward) — forward with attachments
