SendMessage
Send a regular SMS or multimedia MMS message, either to a single recipient or multiple recipients. Each MMS message must be no larger than 1MB in size.
Endpoint
POST (HTTP): https://messaging.esendex.us/Messaging.svc/SendMessage
Syntax
SendMessage(Request)
Request Parameters
Parameter Name | Description | Data Type | Required | Sample Value |
---|---|---|---|---|
Attachments |
Add attachments to message. Can be a URL or MediaID. |
String
|
FALSE (When sending SMS message or Body parameter has a value for MMS message.) | https://i.pinimg.com/736x/01/5.jpg OR 17772 |
Body |
Message content |
String
|
FALSE (When sending MMS message and Attachment parameter has a value.) TRUE (When sending SMS message.) | This is a sample message. |
Subject |
Subject line content of message. |
String
|
False | Esendex test |
LicenseKey |
Your license key, as required to invoke this web service. |
GUID
|
True | F01d89fd-5155-5455-5585-e84ab8de8591 |
From |
DID/short code used to send message. |
String
|
False | 15559080983 |
To |
Recipient number. |
String
|
True | 15551234567 |
Concatenate |
Flag to indicate if concatenation headers should be added to messages that were broken into fragments. |
Boolean
|
False | false |
IsUnicode |
Flag to indicate if message should be sent using Unicode encoding. |
Boolean
|
False | false |
PostbackUrl |
The URL to post call status changes to. The system posts |
String
|
False | http://www.esendex.us/postback.aspx |
ReferenceID |
Unique ID that can be set. |
String
|
False | 123 |
ScheduleDateTime |
UTC date/time when message will send. |
DateTime
|
False | 2020-05-31T11:20:00 |
UseMMS |
Flag when message includes multimedia content. |
Boolean
|
True | true |
Response
Returns: SendMessageResponse
object
Code Samples
// https://messaging.esendex.us/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SendMessage.WSDL;
namespace SendMessage
{
class Program
{
static void Main(string[] args)
{
MessagingClient client = new MessagingClient("mms2wsHttpBinding");
OutgoingMessageRequest req = new OutgoingMessageRequest();
req.Attachments = new string[] { @"https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg" };
req.Body = "";
req.Subject = "";
req.LicenseKey = new Guid("f01d89fd-5155-5455-5585-e84ab8de8591");
req.From = "15559080983";
req.To = new string[] { "15551234567" };
req.Concatenate = false;
req.IsUnicode = false;
req.PostbackUrl = "";
req.ReferenceID = "";
req.ScheduledDateTime = new DateTime(2017, 10, 09, 14, 15, 0).ToUniversalTime();
req.UseMMS = true;
OutgoingMessageResponse[] resp = client.SendMessage(req);
foreach (var item in resp)
{
Console.WriteLine(
"MessageID: " + item.MessageID + Environment.NewLine +
"Message Status: " + item.MessageStatus + Environment.NewLine +
"To: " + item.To + Environment.NewLine +
"From: " + item.From + Environment.NewLine +
"UTC Time Sent: " + item.SentTime + Environment.NewLine +
"Attachments: " + item.Attachments
);
}
Console.ReadLine();
}
}
}
' https://messaging.esendex.us/Messaging.svc?wsdl was added as Service Reference and given the name WSDL
Imports SendMessage.WSDL
Module Module1
Sub Main()
Dim client As WSDL.MessagingClient = New MessagingClient("mms2wsHttpBinding")
Dim req As WSDL.OutgoingMessageRequest = New WSDL.OutgoingMessageRequest()
req.Attachments = New String() {"https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"}
req.Body = ""
req.Subject = "Monkey"
req.LicenseKey = New Guid("f01d89fd-5155-5455-5585-e84ab8de8591")
req.From = "15559080983"
req.To = New String() {"15551234567"}
req.Concatenate = False
req.IsUnicode = False
req.PostbackUrl = "http://esendex.us/postback.aspx"
req.ReferenceID = ""
req.ScheduledDateTime = New DateTime(2017, 10, 9, 14, 15, 0).ToUniversalTime()
req.UseMMS = True
Dim resp As OutgoingMessageResponse() = client.SendMessage(req)
For Each item In resp
Console.WriteLine(
"MessageID: " + Convert.ToString(item.MessageID) + Environment.NewLine +
"Message Status: " + Convert.ToString(item.MessageStatus) + Environment.NewLine +
"To: " + item.To + Environment.NewLine +
"From: " + item.From + Environment.NewLine +
"UTC Time Sent: " + Convert.ToString(item.SentTime) + Environment.NewLine +
"Attachments: " + item.Attachments
)
Next
Console.ReadLine()
End Sub
End Module
Dim cXML
cXML = "<OutgoingMessageRequest xmlns=""http://sms2.esendex.us"">" & _
"<Attachments>" & _
"<string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"">https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg</string>" & _
"</Attachments>" & _
"<Body></Body>" & _
"<Concatenate>false</Concatenate>" & _
"<From>15559080983</From>" & _
"<IsUnicode>false</IsUnicode>" & _
"<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>" & _
"<PostbackUrl></PostbackUrl>" & _
"<ReferenceID></ReferenceID>" & _
"<ScheduledDateTime>2020-05-31T11:20:00</ScheduledDateTime>" & _
"<Subject></Subject>" & _
"<To>" & _
"<string xmlns=""http://schemas.microsoft.com/2003/10/Serialization/Arrays"">15553096094</string>" & _
"</To>" & _
"<UseMMS>true</UseMMS>" & _
"</OutgoingMessageRequest>"
Dim oXMLHTTP
Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
Set oDoc = CreateObject("MSXML2.DOMDocument")
Call oXMLHttp.Open("POST", "https://messaging.esendex.us/Messaging.svc/SendMessage", False)
Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
Call oXMLHttp.send(cXML)
MsgBox oXMLHTTP.responseText
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, MyFile, FileName, TextLine
Set fso = CreateObject("Scripting.FileSystemObject")
FileName = "c:\Users\Desktop\MMS.txt"
Set MyFile = fso.OpenTextFile(FileName, ForWriting, True)
MyFile.WriteLine oXMLHttp.responseText
MyFile.Close
Set MyFile = fso.OpenTextFile(FileName, ForReading)
Do While MyFile.AtEndOfStream <> True
TextLine = MyFile.ReadLine
Loop
MyFile.Close
set request = nothing
<?php
$json = '{
"Attachments":["https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"],
"Body":"",
"Concatenate":false,
"From":"15559080983",
"IsUnicode":false,
"LicenseKey":"f01d89fd-5155-5455-5585-e84ab8de8591",
"PostbackUrl":"http://esendex.us/postback.aspx",
"ReferenceID":"",
"ScheduledDateTime":"\/Date(1239018869048)\/",
"Subject":"",
"To":["15553096094"],
"UseMMS":true
}';
$url = 'https://messaging.esendex.us/Messaging.svc/SendMessage';
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_POST, true);
curl_setopt($cURL, CURLOPT_POSTFIELDS, $json);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
// If you desire your results in XML format, use the following line for your HTTP headers and comment out the HTTP headers code line above.
// curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($cURL);
curl_close($cURL);
$array = json_decode($result, true);
// print_r($json);
// print_r("\n\n\n\n");
print_r($array);
?>
require 'uri'
require 'net/http'
url = URI("https://messaging.esendex.us/Messaging.svc/SendMessage")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = '{
"Attachments": ["https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"],
"Body":"",
"Subject":"",
"LicenseKey": "f01d89fd-5155-5455-5585-e84ab8de8591",
"From" : "15551234567",
"To": ["15551234568"],
"Concatenate":false,
"IsUnicode":false,
"PostBackUrl":"",
"ReferenceID":"",
"ScheduledDateTime":"\/Date(1239018869048)\/",
"UseMMS": true
}'
response = http.request(request)
puts response.read_body
gets response.read_body
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
public final class SendMessage {
public static void main(String[] args) throws Exception {
String responseContent = "";
String response = "";
URL url = new URL("https://messaging.esendex.us/Messaging.svc/SendMessage");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
StringBuilder sb = new StringBuilder("<OutgoingMessageRequest xmlns=\"http://sms2.esendex.us\">");
sb.append("<Attachments>");
sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg</string>");
sb.append("</Attachments>");
sb.append("<Body></Body>");
sb.append("<Concatenate>false</Concatenate>");
sb.append("<From>15559080983</From>");
sb.append("<IsUnicode>false</IsUnicode>");
sb.append("<LicenseKey>f01d89fd-5155-5455-5585-e84ab8de8591</LicenseKey>");
sb.append("<PostBackUrl></PostBackUrl>");
sb.append("<ReferenceID></ReferenceID>");
sb.append("<ScheduledDateTime>2013-01-15T20:53:00.608Z</ScheduledDateTime>");
sb.append("<Subject>Testing Java</Subject>");
sb.append("<To>");
sb.append("<string xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\">15553096094</string>");
sb.append("</To>");
sb.append("<UseMMS>true</UseMMS>");
sb.append("</OutgoingMessageRequest>");
connection.setRequestProperty("Content-Length", String.valueOf(sb.toString().length()));
connection.setRequestProperty("Content-Type", "text/xml");
connection.setRequestProperty("Connection", "Close");
connection.setRequestProperty("SoapAction", "");
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
PrintWriter pw = new PrintWriter(connection.getOutputStream());
pw.write(sb.toString());
pw.flush();
connection.connect();
System.out.println(sb.toString());
BufferedReader br;
if (connection.getResponseCode() == 200) {
br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} else {
br = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
}
while ((responseContent = br.readLine()) != null) {
response += responseContent;
}
System.out.println(response);
}
}
{
"Attachments": [
"https://i.pinimg.com/736x/01/59/40/01594057534c60f94af3165f26d85629--monkey-humor-toddler-christmas.jpg"
],
"Body": "",
"Subject": "",
"LicenseKey": "f01d89fd-5155-5455-5585-e84ab8de8591",
"From": "15551234567",
"To": [
"15551234568"
],
"Concatenate": false,
"IsUnicode": false,
"PostBackURL": "",
"ReferenceID": "",
"ScheduledDateTime": "\/Date(1239018869048)\/",
"UseMMS": true
}