# MailAttachmentUploadLarge

### Summary

* Creates an upload session for large attachments; your client uploads file chunks directly to the provided URL.

### Graph Endpoint

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

### Parameters

#### Required

* `messageId: string` — Alias: `id`
* One of:
  * `attachmentIds: number[]` — Up to 10 repository attachment IDs; backend uploads the files completely.
  * `name: string` — When requesting an upload session (legacy/external upload)

#### Recommended (when requesting an upload session)

* `size: number`

#### Optional

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

### Usage (app.businessFunction)

#### Using repository attachments (recommended)

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

#### Requesting an upload session (external upload)

```js
app.businessFunction({
  functionName: 'MicrosoftGraph',
  methodName: 'Mail',
  operation: 'AttachmentUploadLarge',
  parameters: {
    messageId: 'AAMkAGI2N...',
    name: 'video.mp4',
    size: 104857600,
    contentType: 'video/mp4'
  }
})
```

### Response

```json
// When using attachmentIds
{ "ok": true, "attachments": [ { "id": "...", "name": "video.mp4", "size": 104857600, "contentType": "video/mp4" } ] }

// When requesting an upload session
{ "uploadUrl": "https://...", "expirationDateTime": "2024-09-24T10:00:00Z", "nextExpectedRanges": ["0-"] }
```

### Notes

* Backend handles upload sessions and chunked PUTs for `attachmentIds`. Limit: max 10 attachments per call.
* If you request an upload session, upload file chunks to `uploadUrl` using HTTP `PUT` with byte ranges as described in Microsoft Graph documentation.

#### 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
