---
title: setMaxRecipients
slug: campaign/docs/setmaxrecipients
docTags: 
createdAt: 2026-07-02T19:01:45.941Z
---

The mailing must be of the type regular.

See also [setMaxRecipientsPercentage](docId\:zbUiH36OhO6h1em_-HiQF).

**Type**: void

**Parameters**

| Name          | Type    | Value                                                                                                                 |
| ------------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
| sessionId     | String  | ID of the session                                                                                                     |
| mailingId     | long    | ID of the mailing                                                                                                     |
| maxRecipients | int     | Maximum number of recipients. The value -1 means All (no maximum number of recipients set).                           |
| randomOrder   | Boolean | TRUE: Recipients are selected on a random basis; FALSE: Recipients are selected by their ID starting with the lowest. |

**Return values**: -

**Code structure**

```javascript
void setMaxRecipients(String sessionId, long mailingId, int maxRecipients, boolean randomOrder)
```
