Send and receive SMS messages from a C# application
You're building a C# application and want to send messages SMS. Use our HTTP or REST API to send messages to a mobile number in your development environment. Whether it's an alert message or a marketing campaign, you can send and receive SMS messages directly from any C# application.
The advantages of sending SMS in C#
A API SMS compatible with the C# programming language is a gateway that allows you to connect directly to our SMS platform.
Quick and easy API integration
Compatible with all programming languages for HTTP GET and POST requests, our comprehensive, free documentation makes integration quick and easy.
Maximum safety
Hosted in France, in a level 4 data-center, our SMS APIs guarantee maximum security, thanks in particular to the HTTPS protocol. Our platform is ISO 27001 & 27701 certified.
Continuous service
Our infrastructure is monitored 24 hours a day, 7 days a week, 365 days a year, to ensure high availability and resistance to failure.
Technical support at your service
Our dedicated team of developers is available to help you integrate our APIs SMS or answer any questions you may have.
STARTER GUIDE
How to send SMS in C#?
Setting up our webservice in your C# development is quick and easy. The C# Next code example gives you a brief overview of how to add SMS functionality to your website or application.
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text;
using System.Web;
/**
* Function parameters:
*
* - accessToken (required)
* - message (required)
* - destinataires (required): Receivers separated by a comma
* - emetteur (optional): Allows to deal with the sms sender
* - optionStop (optional): Deal with the STOP sms when marketing send (cf. API HTTP documentation)
* - batchFilePath (required for batch mode): The path of CSV file for sms in Batch Mode
*/
namespace ExempleClientHttpApi
{
public class ExempleClientHttpApi {
private static string URL = "https://api.smsmode.com/http/1.6/";
private static string PATH_SEND_SMS = "sendSMS.do";
private static string PATH_SEND_SMS_BATCH = "sendSMSBatch.do";
private static string ERROR_API = "Error during API call\n";
private static string ERROR_FILE = "The specified file does not exist\n";
private static readonly HttpClient _httpClient= new HttpClient();
public ExempleClientHttpApi()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
}
// send SMS with GET method
public string sendSmsGet(string accessToken, string message, string destinataires, string emetteur, string optionStop) {
string urlEncodedMessage = HttpUtility.UrlEncode(message, Encoding.GetEncoding("ISO-8859-15"));
string finalUrl = URL + PATH_SEND_SMS + "?accessToken=" + accessToken + "&numero=" + destinataires + "&message=" + urlEncodedMessage + "&emetteur=" + emetteur + "&stop=" + optionStop;
return Get(finalUrl).Result;
}
public static async Task Get(string url){
try {
var response = await _httpClient.GetAsync(url);
string result = await response.Content.ReadAsStringAsync();
return result;
} catch (Exception) {
return ERROR_API;
}
}
// send SMS with POST method
public string sendSmsPost(string accessToken, string message, string destinataires, string emetteur, string optionStop) {
string finalUrl = URL + PATH_SEND_SMS;
StringBuilder sb = new StringBuilder();
sb.Append("accessToken=" + accessToken);
sb.Append("&numero=" + destinataires);
sb.Append("&emetteur=" + emetteur);
sb.Append("&message=" + HttpUtility.UrlEncode(message, Encoding.GetEncoding("ISO-8859-15")));
sb.Append("&stop=" + optionStop);
return Post(finalUrl ,Encoding.Default.GetBytes(sb.ToString())).Result;
}
public static async Task Post(string url, byte[] data){
ByteArrayContent byteContent = new ByteArrayContent(data);
byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
try {
var response = await _httpClient.PostAsync(url, byteContent);
string result = await response.Content.ReadAsStringAsync();
return result;
} catch (Exception) {
return ERROR_API;
}
}
// send SMS with POST method (batch)
public string sendSmsBatch(string accessToken, string batchFilePath, string optionStop) {
if (!File.Exists(batchFilePath)) {
return ERROR_FILE;
}
string finalUrl = URL + PATH_SEND_SMS_BATCH + "?accessToken=" + accessToken + "&stop=" + optionStop;
return PostBatch(finalUrl , File.ReadAllBytes(batchFilePath), batchFilePath).Result;
}
public static async Task PostBatch(string url, byte[] data, string batchFilePath) {
var requestContent = new MultipartFormDataContent();
ByteArrayContent byteContent = new ByteArrayContent(data);
byteContent.Headers.ContentType = MediaTypeHeaderValue.Parse("text/csv");
requestContent.Add(byteContent, "file", batchFilePath);
try {
var response = await _httpClient.PostAsync(url, requestContent);
string result = await response.Content.ReadAsStringAsync();
return result;
} catch (Exception) {
return ERROR_API;
}
}
}
}
The full documentation of our HTTPs API details all the functions and requests available on our gateway. SMS
The C# SDK lets you configure :
- Check your remaining credit
- Send a SMS to multiple recipients
- Manage your contacts
- Set the sending date and time
- Send notifications by SMS
- Receive statistics on campaigns sent (status received)
It is compatible with :
ISO-8859-15
PHP
Java
ASP
C++
Ruby
WINDEV
Why use our SMS gateway?
Mobile messaging platform for professionals since 2004, smsmode© has developed numerous service guarantees. The company is committed to continuous improvement of its performance and the quality of its shipping service.
Self-service platform service
With no subscription fees or fixed costs, our HTTP API is open source, free of charge and without obligation. You'll only be charged for the cost of the SMS sent (which decreases according to the volume sent)!
Telecom operator ARCEP
Our SMS shipments are direct to French operators (no roaming in France or worldwide). You're assured of a reliable service at a competitive price.
Separation of traffic
Marketing and notification channels are thus handled independently, offering optimized performance. Sending speed is higher, STOP management more reliable, etc.
Real-time monitoring of shipments
Benefit from a constant alert and monitoring system. The status of traffic passing through our webservice is visible in real time. You can check system status at any time via our StatusPage.
Wide range of tools
Additional services are available for more advanced use of the SMS marketing reception, database optimization, SMS voice, white label, OTP passwordpassword, etc.
Highly responsive support
Our support & development teams are on hand to answer your technical questions, and help you implement our API in C#. You can also consult our full documentation.
Create your free account
Try out our SMS platform and benefit from 20 free test credits, with no obligation.