<!-- source: docs/api/2_capi/mail/index.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/capi/mail -->

# Mail

The Mail service allows you to send emails though brainCloud using the mail service provider you have configured on the [Manage Integrations page](https://portal.braincloudservers.com/admin/dashboard#/development/integrations-manage-integrations) of the brainCloud portal.

### Advanced Parameters

Using the SendAdvancedEmail method you can specify service-specific parameters to use when sending an email. Things like tags, categories, templates, and substitutions.
The available parameters will depend on the mail service provider you have enabled.

### SendGrid

> Example of dynamic templated SendGrid email parameters:

```json
{
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": ["xxx@company.com"],
    "bcc": ["yyy@company.com"],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": ["category1", "category2"],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
}
```

Mail template formats sent into SendGrid.

Information on setting up SendGrid can be found [here](/learn/portal-tutorials/email-integration-sendgrid/).

### General Template Parameters

| Parameter      | Description                                                      |
| -------------- | ---------------------------------------------------------------- |
| fromAddress    | An alternate from address.                                       |
| fromName       | An alternate from name.                                          |
| replyToAddress | An alternate reply-to address.                                   |
| replyToName    | An alternate reply-to name.                                      |
| cc             | Array of email addresses to cc.                                  |
| bcc            | Array of email addresses to bcc.                                 |
| templateId     | The templateId of the SendGrid template to use for this message. |
| categories     | Additional category tags for this email.                         |
| attachments    | File attachments.                                                |

### Dyanmic Template Parameters

| Parameter   | Description         |
| ----------- | ------------------- |
| dynamicData | Dynamic email data. |

### HTML/plain-text Template Parameters

| Parameter | Description                            |
| --------- | -------------------------------------- |
| useHtml   | Should display email contents in html. |
| subject   | The email subject                      |
| body      | The email body                         |

### Legacy Template Parameters

| Parameter     | Description                                                                     |
| ------------- | ------------------------------------------------------------------------------- |
| substitutions | Substitutions to use in the specified template. Only valid if template is used. |

### API Summary

### Send Mail

-   [SendBasicEmail](/api/capi/mail/sendbasicemail) - simplified send an email to a profile id.
-   [SendAdvancedEmail](/api/capi/mail/sendadvancedemail) - send an email with to a profile id.
-   [SendAdvancedEmailByAddress](/api/capi/mail/sendadvancedemailbyaddress) - send an email to an email address.
-   [SendAdvancedEmailByAddresses](/api/capi/mail/sendadvancedemailbyaddresses) - send an advanced email to the address specified.


---

<!-- source: docs/api/2_capi/mail/sendadvancedemail.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/capi/mail/sendadvancedemail -->

# SendAdvancedEmail

Sends an advanced email to the specified user.

> **Tip:** The advanced API takes a set of parameters that are
> dependant on the mail service configured in the brainCloud Portal.
> For a list of all available parameters see the top of the Mail service documentation.

| Service | Operation |
| ------- | --------- |
| mail | SEND_ADVANCED_EMAIL |

## Method Parameters

| Parameter     | Description                                                |
| ------------- | ---------------------------------------------------------- |
| profileId     | The user to send the email to                              |
| serviceParams | Set of parameters dependant on the mail service configured |

## Usage

**C#:**

```csharp
string profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
string jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
SuccessCallback successCallback = (response, cbObject) =>
{
    Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
    Debug.Log(string.Format("Failed | {0}  {1}  {2}", status, code, error));
};

_bc.MailService.SendAdvancedEmail(profileId, jsonServiceParams, successCallback, failureCallback);
```

**C++:**

```cpp
const char *profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
const char *jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
_bc->getMailService()->sendAdvancedEmail(profileId, jsonServiceParams, this);
```

**Obj-C:**

```objectivec
NSString *profileId = @"f7144cc0-b996-440f-8459-21b0ecb91a10";
NSString *jsonServiceParams = @"{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
BCCompletionBlock successBlock;      // define callback
BCErrorCompletionBlock failureBlock; // define callback

[[_bc mailService] sendAdvancedEmail:profileId
          jsonServiceParams:jsonServiceParams
            completionBlock:successBlock
       errorCompletionBlock:failureBlock
                   cbObject:nil];
```

**Java:**

```java
String profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
String jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
this; // implements IServerCallback

_bc.getMailService().sendAdvancedEmail(profileId, jsonServiceParams, this);

public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
    System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
    System.out.print(String.format("Failed | %d %d %s", statusCode,  reasonCode, jsonError.toString()));
}
```

**JavaScript:**

```javascript
var profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var jsonServiceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};

_bc.mail.sendAdvancedEmail(profileId, jsonServiceParams, result =>
{
    var status = result.status;
    console.log(status + " : " + JSON.stringify(result, null, 2));
});
```

**Dart:**

```dart
var  profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var  jsonServiceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};

ServerResponse result = await _bc.mailService.sendAdvancedEmail(profileId:profileId, serviceParams:serviceParams);

if (result.statusCode == 200) {
    print("Success");
} else {
    print("Failed ${result.error['status_message'] ?? result.error}");
}
```

**Roblox:**

```lua
local profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10"
local serviceParams = {
    fromAddress = "email@company.com",
    fromName = "Jane Doe",
    replyToAddress = "optional@company.com",
    replyToName = "Optional ReplyTo",
    templateId = "d-www-xxx-yyy-zzz",
    dynamicData = {
        user = { firstName = "John", lastName = "Doe" },
        resetLink = "www.dummuyLink.io"
    },
    categories = { "category1", "category2" },
    attachments = {
        {
            content = "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            filename = "attachment.txt"
        }
    }
}

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendAdvancedEmail(profileId, serviceParams, callback)
```

**GDScript:**

```gdscript
var profile_id = "f7144cc0-b996-440f-8459-21b0ecb91a10"
var json_service_params = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
}

var result = await _bc.mail_service.send_advanced_email(profile_id, serviceParams)

if result.status == 200:
	print("Success")
else:
	print("Failed: %s" % result.status_message)
```

**Lua:**

```lua
local profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10"
local serviceParams = {
    fromAddress = "email@company.com",
    fromName = "Jane Doe",
    replyToAddress = "optional@company.com",
    replyToName = "Optional ReplyTo",
    templateId = "d-www-xxx-yyy-zzz",
    dynamicData = {
        user = { firstName = "John", lastName = "Doe" },
        resetLink = "www.dummuyLink.io"
    },
    categories = { "category1", "category2" },
    attachments = {
        {
            content = "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            filename = "attachment.txt"
        }
    }
}

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendAdvancedEmail(profileId, serviceParams, callback)
```

**Cloud Code:**

```cfscript
var profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var jsonServiceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};
var mailProxy = bridge.getMailServiceProxy();

var postResult = mailProxy.sendAdvancedEmail(profileId, jsonServiceParams);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```json
{
    "service": "mail",
    "operation": "SEND_ADVANCED_EMAIL",
    "data": {
        "profileId": "f7144cc0-b996-440f-8459-21b0ecb91a10",
        "serviceParams": {
            "fromAddress": "email@company.com",
            "fromName": "Jane Doe",
            "replyToAddress": "optional@company.com",
            "replyToName": "Optional ReplyTo",
            "templateId": "d-www-xxx-yyy-zzz",
            "dynamicData": {
                "user": {
                    "firstName": "John",
                    "lastName": "Doe"
                },
                "resetLink": "www.dummuyLink.io"
            },
            "categories": ["category1", "category2"],
            "attachments": [
                {
                    "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
                    "filename": "attachment.txt"
                }
            ]
        }
    },
    "status": 200
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": {},
    "status": 200
}
```

</details>


---

<!-- source: docs/api/2_capi/mail/sendadvancedemailbyaddress.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/capi/mail/sendadvancedemailbyaddress -->

# SendAdvancedEmailByAddress

Sends an advanced email to the specified email address.

> **Tip:** The advanced API takes a set of parameters that are
> dependant on the mail service configured in the brainCloud Portal.
> For a list of all available parameters see the top of the Mail service documentation.

| Service | Operation |
| ------- | --------- |
| mail | SEND_ADVANCED_EMAIL_BY_ADDRESS |

## Method Parameters

| Parameter     | Description                                                |
| ------------- | ---------------------------------------------------------- |
| emailAddress  | The address to send the email to                           |
| serviceParams | Set of parameters dependant on the mail service configured |

## Usage

**C#:**

```csharp
string emailAddress = "test@email.com";
string jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
SuccessCallback successCallback = (response, cbObject) =>
{
    Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
    Debug.Log(string.Format("Failed | {0}  {1}  {2}", status, code, error));
};

_bc.MailService.SendAdvancedEmailByAddress(emailAddress, jsonServiceParams, successCallback, failureCallback);
```

**C++:**

```cpp
const char *emailAddress = "test@email.com";
const char *jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
_bc->getMailService()->sendAdvancedEmailByAddress(emailAddress, jsonServiceParams, this);
```

**Obj-C:**

```objectivec
NSString *emailAddress = @"test@email.com";
NSString *jsonServiceParams = @"{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
BCCompletionBlock successBlock;      // define callback
BCErrorCompletionBlock failureBlock; // define callback

[[_bc mailService] sendAdvancedEmailByAddress:emailAddress
          jsonServiceParams:jsonServiceParams
            completionBlock:successBlock
       errorCompletionBlock:failureBlock
                   cbObject:nil];
```

**Java:**

```java
String emailAddress = "test@email.com";
String jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
this; // implements IServerCallback

_bc.getMailService().sendAdvancedEmailByAddress(emailAddress, jsonServiceParams, this);

public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
    System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
    System.out.print(String.format("Failed | %d %d %s", statusCode,  reasonCode, jsonError.toString()));
}
```

**JavaScript:**

```javascript
var emailAddress = "test@email.com";
var jsonServiceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": [
        "xxx@company.com"
    ],
    "bcc": [
        "yyy@company.com"
    ],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};

_bc.mail.sendAdvancedEmailByAddress(emailAddress, jsonServiceParams, result =>
{
    var status = result.status;
    console.log(status + " : " + JSON.stringify(result, null, 2));
});
```

**Dart:**

```dart
var  emailAddress = "test@email.com";
var  serviceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": [
        "xxx@company.com"
    ],
    "bcc": [
        "yyy@company.com"
    ],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};

ServerResponse result = await _bc.mailService.sendAdvancedEmailByAddress(emailAddress:emailAddress, serviceParams:serviceParams);

if (result.statusCode == 200) {
    print("Success");
} else {
    print("Failed ${result.error['status_message'] ?? result.error}");
}
```

**Roblox:**

```lua
local emailAddress = "test@email.com"
local serviceParams = {
    fromAddress = "email@company.com",
    fromName = "Jane Doe",
    replyToAddress = "optional@company.com",
    replyToName = "Optional ReplyTo",
    cc = { "xxx@company.com" },
    bcc = { "yyy@company.com" },
    templateId = "d-www-xxx-yyy-zzz",
    dynamicData = {
        user = { firstName = "John", lastName = "Doe" },
        resetLink = "www.dummuyLink.io"
    },
    categories = { "category1", "category2" },
    attachments = {
        {
            content = "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            filename = "attachment.txt"
        }
    }
}

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendAdvancedEmailByAddress(emailAddress, serviceParams, callback)
```

**GDScript:**

```gdscript
var email_address = "test@email.com"
var service_params = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": [
        "xxx@company.com"
    ],
    "bcc": [
        "yyy@company.com"
    ],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
}

var result = await _bc.mail_service.send_advanced_email_by_address(email_address, service_params)

if result.status == 200:
	print("Success")
else:
	print("Failed: %s" % result.status_message)
```

**Lua:**

```lua
local emailAddress = "test@email.com"
local serviceParams = {
    fromAddress = "email@company.com",
    fromName = "Jane Doe",
    replyToAddress = "optional@company.com",
    replyToName = "Optional ReplyTo",
    cc = { "xxx@company.com" },
    bcc = { "yyy@company.com" },
    templateId = "d-www-xxx-yyy-zzz",
    dynamicData = {
        user = { firstName = "John", lastName = "Doe" },
        resetLink = "www.dummuyLink.io"
    },
    categories = { "category1", "category2" },
    attachments = {
        {
            content = "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            filename = "attachment.txt"
        }
    }
}

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendAdvancedEmailByAddress(emailAddress, serviceParams, callback)
```

**Cloud Code:**

```cfscript
var emailAddress = "test@email.com";
var jsonServiceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": [
        "xxx@company.com"
    ],
    "bcc": [
        "yyy@company.com"
    ],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};
var mailProxy = bridge.getMailServiceProxy();

var postResult = mailProxy.sendAdvancedEmailByAddress(emailAddress, jsonServiceParams);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```json
{
    "service": "mail",
    "operation": "SEND_ADVANCED_EMAIL_BY_ADDRESS",
    "data": {
        "emailAddress": "test@email.com",
        "serviceParams": {
            "fromAddress": "email@company.com",
            "fromName": "Jane Doe",
            "replyToAddress": "optional@company.com",
            "replyToName": "Optional ReplyTo",
            "templateId": "d-www-xxx-yyy-zzz",
            "dynamicData": {
                "user": {
                    "firstName": "John",
                    "lastName": "Doe"
                },
                "resetLink": "www.dummuyLink.io"
            },
            "categories": ["category1", "category2"],
            "attachments": [
                {
                    "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
                    "filename": "attachment.txt"
                }
            ]
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": {},
    "status": 200
}
```

</details>


---

<!-- source: docs/api/2_capi/mail/sendadvancedemailbyaddresses.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/capi/mail/sendadvancedemailbyaddresses -->

# SendAdvancedEmailByAddresses

Sends an advanced email to the address specified.

> **Tip:** The advanced API takes a set of parameters that are
> dependant on the mail service configured in the brainCloud Portal.
> For a list of all available parameters see the top of the Mail service documentation.

| Service | Operation |
| ------- | --------- |
| mail | SEND_ADVANCED_EMAIL_BY_ADDRESSES |

## Method Parameters

| Parameter      | Description                                                |
| -------------- | ---------------------------------------------------------- |
| emailAddresses | The list of addresses to send the email to                 |
| serviceParams  | Set of parameters dependant on the mail service configured |

## Usage

**C#:**

```csharp
string[] emailAddresses = {"test@email.com", "anothertest@email.com"};
string jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
SuccessCallback successCallback = (response, cbObject) =>
{
    Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
    Debug.Log(string.Format("Failed | {0}  {1}  {2}", status, code, error));
};

_bc.MailService.SendAdvancedEmailByAddresses(emailAddresses, jsonServiceParams, successCallback, failureCallback);
```

**C++:**

```cpp
std::vector<std::string> emailAddresses;
emailAddresses.push_back("test@email.com");
emailAddresses.push_back("anothertest@email.com");
const char *jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
_bc->getMailService()->sendAdvancedEmailByAddresses(emailAddresses, jsonServiceParams, this);
```

**Obj-C:**

```objectivec
NSArray *emailAddresses = @[ @"test@email.com", @"anothertest@email.com" ];
NSString *jsonServiceParams = @"{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
BCCompletionBlock successBlock;      // define callback
BCErrorCompletionBlock failureBlock; // define callback

[[_bc mailService] sendAdvancedEmailByAddresses:emailAddresses
          jsonServiceParams:jsonServiceParams
            completionBlock:successBlock
       errorCompletionBlock:failureBlock
                   cbObject:nil];
```

**Java:**

```java
String[] emailAddresses = {"test@email.com", "anothertest@email.com"};
String jsonServiceParams = "{\"fromAddress\":\"email@company.com\",\"fromName\":\"Jane Doe\",\"replyToAddress\":\"optional@company.com\",\"replyToName\":\"Optional ReplyTo\",\"templateId\":\"d-www-xxx-yyy-zzz\",\"dynamicData\":{\"user\":{\"firstName\":\"John\",\"lastName\":\"Doe\"},\"resetLink\":\"www.dummuyLink.io\"},\"categories\":[\"category1\",\"category2\"],\"attachments\":[{\"content\":\"VGhpcyBhdHRhY2htZW50IHRleHQ=\",\"filename\":\"attachment.txt\"}]}";
this; // implements IServerCallback

_bc.getMailService().sendAdvancedEmailByAddresses(emailAddresses, jsonServiceParams, this);

public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
    System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
    System.out.print(String.format("Failed | %d %d %s", statusCode,  reasonCode, jsonError.toString()));
}
```

**JavaScript:**

```javascript
var emailAddresses = ["test@email.com", "anothertest@email.com"];
var jsonServiceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": [
        "xxx@company.com"
    ],
    "bcc": [
        "yyy@company.com"
    ],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};

_bc.mail.sendAdvancedEmailByAddresses(emailAddresses, jsonServiceParams, result =>
{
    var status = result.status;
    console.log(status + " : " + JSON.stringify(result, null, 2));
});
```

**Dart:**

```dart
var  emailAddresses = ["test@email.com", "anothertest@email.com"];
var  serviceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": [
        "xxx@company.com"
    ],
    "bcc": [
        "yyy@company.com"
    ],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};

ServerResponse result = await _bc.mailService.sendAdvancedEmailByAddresses(emailAddresses:emailAddresses, serviceParams:serviceParams);

if (result.statusCode == 200) {
    print("Success");
} else {
    print("Failed ${result.error['status_message'] ?? result.error}");
}
```

**Roblox:**

```lua
local emailAddresses = { "test@email.com", "anothertest@email.com" }
local serviceParams = {
    fromAddress = "email@company.com",
    fromName = "Jane Doe",
    replyToAddress = "optional@company.com",
    replyToName = "Optional ReplyTo",
    cc = { "xxx@company.com" },
    bcc = { "yyy@company.com" },
    templateId = "d-www-xxx-yyy-zzz",
    dynamicData = {
        user = { firstName = "John", lastName = "Doe" },
        resetLink = "www.dummuyLink.io"
    },
    categories = { "category1", "category2" },
    attachments = {
        {
            content = "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            filename = "attachment.txt"
        }
    }
}

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendAdvancedEmailByAddresses(emailAddresses, serviceParams, callback)
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
local emailAddresses = { "test@email.com", "anothertest@email.com" }
local serviceParams = {
    fromAddress = "email@company.com",
    fromName = "Jane Doe",
    replyToAddress = "optional@company.com",
    replyToName = "Optional ReplyTo",
    cc = { "xxx@company.com" },
    bcc = { "yyy@company.com" },
    templateId = "d-www-xxx-yyy-zzz",
    dynamicData = {
        user = { firstName = "John", lastName = "Doe" },
        resetLink = "www.dummuyLink.io"
    },
    categories = { "category1", "category2" },
    attachments = {
        {
            content = "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            filename = "attachment.txt"
        }
    }
}

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendAdvancedEmailByAddresses(emailAddresses, serviceParams, callback)
```

**Cloud Code:**

```cfscript
var emailAddresses = ["test@email.com", "anothertest@email.com"];
var jsonServiceParams = {
    "fromAddress": "email@company.com",
    "fromName": "Jane Doe",
    "replyToAddress": "optional@company.com",
    "replyToName": "Optional ReplyTo",
    "cc": [
        "xxx@company.com"
    ],
    "bcc": [
        "yyy@company.com"
    ],
    "templateId": "d-www-xxx-yyy-zzz",
    "dynamicData": {
        "user": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ],
    "attachments": [
        {
            "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
            "filename": "attachment.txt"
        }
    ]
};
var mailProxy = bridge.getMailServiceProxy();

var postResult = mailProxy.sendAdvancedEmailByAddresses(emailAddresses, jsonServiceParams);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "mail",
    "operation": "SEND_ADVANCED_EMAIL_BY_ADDRESSES",
    "data": {
        "emailAddresses": ["test@email.com", "anothertest@email.com"],
        "serviceParams": {
            "fromAddress": "email@company.com",
            "fromName": "Jane Doe",
            "replyToAddress": "optional@company.com",
            "replyToName": "Optional ReplyTo",
            "templateId": "d-www-xxx-yyy-zzz",
            "dynamicData": {
                "user": {
                    "firstName": "John",
                    "lastName": "Doe"
                },
                "resetLink": "www.dummuyLink.io"
            },
            "categories": ["category1", "category2"],
            "attachments": [
                {
                    "content": "VGhpcyBhdHRhY2htZW50IHRleHQ=",
                    "filename": "attachment.txt"
                }
            ]
        }
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": {},
    "status": 200
}
```

</details>


---

<!-- source: docs/api/2_capi/mail/sendbasicemail.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/capi/mail/sendbasicemail -->

# SendBasicEmail

Sends a simple text email to the specified user.

| Service | Operation |
| ------- | --------- |
| mail | SEND_BASIC_EMAIL |

## Method Parameters

| Parameter | Description                   |
| --------- | ----------------------------- |
| profileId | The user to send the email to |
| subject   | The email subject             |
| body      | The email body                |

## Usage

**C#:**

```csharp
string profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
string subject = "Basic email subject";
string body = "This is the body of the email";
SuccessCallback successCallback = (response, cbObject) =>
{
    Debug.Log(string.Format("Success | {0}", response));
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
    Debug.Log(string.Format("Failed | {0}  {1}  {2}", status, code, error));
};

_bc.MailService.SendBasicEmail(profileId, subject, body, successCallback, failureCallback);
```

**C++:**

```cpp
const char *profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
const char *subject = "Basic email subject";
const char *body = "This is the body of the email";
_bc->getMailService()->sendBasicEmail(profileId, subject, body, this);
```

**Obj-C:**

```objectivec
NSString *profileId = @"f7144cc0-b996-440f-8459-21b0ecb91a10";
NSString *subject = @"Basic email subject";
NSString *body = @"This is the body of the email";
BCCompletionBlock successBlock;      // define callback
BCErrorCompletionBlock failureBlock; // define callback

[[_bc mailService] sendBasicEmail:profileId
                    subject:subject
                       body:body
            completionBlock:successBlock
       errorCompletionBlock:failureBlock
                   cbObject:nil];
```

**Java:**

```java
String profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
String subject = "Basic email subject";
String body = "This is the body of the email";
this; // implements IServerCallback

_bc.getMailService().sendBasicEmail(profileId, subject, body, this);

public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
    System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
    System.out.print(String.format("Failed | %d %d %s", statusCode,  reasonCode, jsonError.toString()));
}
```

**JavaScript:**

```javascript
var profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var subject = "Basic email subject";
var body = "This is the body of the email";

_bc.mail.sendBasicEmail(profileId, subject, body, result =>
{
    var status = result.status;
    console.log(status + " : " + JSON.stringify(result, null, 2));
});
```

**Dart:**

```dart
var  profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var  subject = "Basic email subject";
var  body = "This is the body of the email";

ServerResponse result = await _bc.mailService.sendBasicEmail(profileId:profileId, subject:subject, body:body);

if (result.statusCode == 200) {
    print("Success");
} else {
    print("Failed ${result.error['status_message'] ?? result.error}");
}
```

**Roblox:**

```lua
local profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10"
local subject = "Basic email subject"
local body = "This is the body of the email"

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendBasicEmail(profileId, subject, body, callback)
```

**GDScript:**

```gdscript
var profile_id = "f7144cc0-b996-440f-8459-21b0ecb91a10"
var subject = "Basic email subject"
var body = "This is the body of the email"

var result = await _bc.mail_service.send_basic_email(profile_id, subject, body)

if result.status == 200:
	print("Success")
else:
	print("Failed: %s" % result.status_message)
```

**Lua:**

```lua
local profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10"
local subject = "Basic email subject"
local body = "This is the body of the email"

local callback = function(success, response)
    if success then
        print("Success")
    else
        print("Failed | " .. tostring(response.status_message))
    end
end

_bc.mail:sendBasicEmail(profileId, subject, body, callback)
```

**Cloud Code:**

```cfscript
var profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var subject = "Basic email subject";
var body = "This is the body of the email";
var mailProxy = bridge.getMailServiceProxy();

var postResult = mailProxy.sendBasicEmail(profileId, subject, body);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "mail",
    "operation": "SEND_BASIC_EMAIL",
    "data": {
        "profileId": "f7144cc0-b996-440f-8459-21b0ecb91a10",
        "subject": "Basic email subject",
        "body": "This is the body of the email"
    }
}
```

<details>
<summary>JSON Response</summary>

```json
{
    "data": {},
    "status": 200
}
```

</details>


---

<!-- source: docs/api/4_s2s/mail/index.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/s2s/mail -->

# Mail

The Mail service allows you to send emails though brainCloud using the mail service provider you have configured on the [Manage Integrations page](https://portal.braincloudservers.com/admin/dashboard#/development/integrations-manage-integrations) of the brainCloud portal.

### API Summary

### Mail

-   [SendBasicEmail](/api/s2s/mail/sendbasicemail) - Sends a simple text email to the given user.
-   [SendAdvancedEmail](/api/s2s/mail/sendadvancedemail) - Sends a advanced email to the given user.
-   [SendAdvancedEmailByAddress](/api/s2s/mail/sendadvancedemailbyaddress) - Sends a advanced email to the given user.
-   [SendAdvancedEmailByAddresses](/api/capi/mail/sendadvancedemailbyaddresses) - Sends an advanced email to the address specified.


---

<!-- source: docs/api/4_s2s/mail/sendadvancedemail.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/s2s/mail/sendadvancedemail -->

# SendAdvancedEmail

Sends a advanced email to the given user.
See the documentation for contents of 'serviceParams'.

| Service | Operation |
| ------- | --------- |
| mail | SEND_ADVANCED_EMAIL |

## Method Parameters

| Parameter     | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| profileId     | The user to send the email to.                              |
| serviceParams | Set of parameters dependant on the mail service configured. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var serviceParams = {
    "fromAddress": "fromAddress",
    "fromName": "fromName",
    "replyToAddress": "replyToAddress",
    "replyToName": "replyToName",
    "templateId": "8f14c77d-61f4-4966-ab6d-0bee8b13d090",
    "subject": "subject",
    "body": "Body goes here",
    "useHtml": false,
    "substitutions": {
        ":name": "John Doe",
        ":resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ]
};
var mailProxy = bridge.getMailServiceProxy();

var postResult = mailProxy.sendAdvancedEmail(profileId, serviceParams);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "mail",
    "operation": "SEND_ADVANCED_EMAIL",
    "data": {
        "profileId": "f7144cc0-b996-440f-8459-21b0ecb91a10",
        "serviceParams": {
            "fromAddress": "fromAddress",
            "fromName": "fromName",
            "replyToAddress": "replyToAddress",
            "replyToName": "replyToName",
            "templateId": "8f14c77d-61f4-4966-ab6d-0bee8b13d090",
            "subject": "subject",
            "body": "Body goes here",
            "useHtml": false,
            "substitutions": {
                ":name": "John Doe",
                ":resetLink": "www.dummuyLink.io"
            },
            "categories": [
                "category1",
                "category2"
            ]
        }
    }
}
```


---

<!-- source: docs/api/4_s2s/mail/sendadvancedemailbyaddress.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/s2s/mail/sendadvancedemailbyaddress -->

# SendAdvancedEmailByAddress

Sends a advanced email to the given user.
See the documentation for contents of 'serviceParams'.

| Service | Operation |
| ------- | --------- |
| mail | SEND_ADVANCED_EMAIL_BY_ADDRESS |

## Method Parameters

| Parameter     | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| emailAddress  | The address to send the email to.                           |
| serviceParams | Set of parameters dependant on the mail service configured. |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var emailAddress = "test@email.com";
var serviceParams = {
    "fromAddress": "fromAddress",
    "fromName": "fromName",
    "replyToAddress": "replyToAddress",
    "replyToName": "replyToName",
    "templateId": "8f14c77d-61f4-4966-ab6d-0bee8b13d090",
    "subject": "subject",
    "body": "Body goes here",
    "useHtml": false,
    "substitutions": {
        ":name": "John Doe",
        ":resetLink": "www.dummuyLink.io"
    },
    "categories": [
        "category1",
        "category2"
    ]
};
var mailProxy = bridge.getMailServiceProxy();

var postResult = mailProxy.sendAdvancedEmailByAddress(emailAddress, serviceParams);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "mail",
    "operation": "SEND_ADVANCED_EMAIL_BY_ADDRESS",
    "data": {
        "emailAddress": "test@email.com",
        "serviceParams": {
            "fromAddress": "fromAddress",
            "fromName": "fromName",
            "replyToAddress": "replyToAddress",
            "replyToName": "replyToName",
            "templateId": "8f14c77d-61f4-4966-ab6d-0bee8b13d090",
            "subject": "subject",
            "body": "Body goes here",
            "useHtml": false,
            "substitutions": {
                ":name": "John Doe",
                ":resetLink": "www.dummuyLink.io"
            },
            "categories": [
                "category1",
                "category2"
            ]
        }
    }
}
```


---

<!-- source: docs/api/4_s2s/mail/sendbasicemail.md -->
<!-- url: https://docs-internal.braincloudservers.com/api/s2s/mail/sendbasicemail -->

# SendBasicEmail

Sends a simple text email to the given user.

| Service | Operation |
| ------- | --------- |
| mail | SEND_BASIC_EMAIL |

## Method Parameters

| Parameter | Description                    |
| --------- | ------------------------------ |
| profileId | The user to send the email to. |
| subject   | Subject of the email.          |
| body      | Body of the email.             |

## Usage

**C#:**

```csharp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**C++:**

```cpp
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Obj-C:**

```objectivec
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Java:**

```java
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**JavaScript:**

```javascript
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Dart:**

```dart
// S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Roblox:**

```lua
-- N/A
```

**GDScript:**

```gdscript
N/A
```

**Lua:**

```lua
-- S2S call: to view example, switch to the Cloud Code or Raw tab.
```

**Cloud Code:**

```cfscript
var profileId = "f7144cc0-b996-440f-8459-21b0ecb91a10";
var subject = "Basic email subject";
var body = "This is the body of the email";
var mailProxy = bridge.getMailServiceProxy();

var postResult = mailProxy.sendBasicEmail(profileId, subject, body);
if (postResult.status == 200) {
    // Success!
}
```

**Raw:**

```r
{
    "service": "mail",
    "operation": "SEND_BASIC_EMAIL",
    "data": {
        "profileId": "f7144cc0-b996-440f-8459-21b0ecb91a10",
        "subject": "Basic email subject",
        "body": "This is the body of the email"
    }
}
```
