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 |
---|---|
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
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
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);
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);
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];
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()));
}
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));
});
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}");
}
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!
}
{
"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"
}
]
}
}
}
JSON Response
{
"status": 200,
"data": {}
}