C#

C# SMS API Wrapper

Send sms text messages using our C# wrapper.
It’s simple and easy to use. Here it is!

Step 1.
Create a new C# or Visual Basic project. NOTE: Must target .NET 4.5.2

Step 2.
Right click on your project and click “Manage NuGet Packages…”

Step 3.
In the “Manage NuGet Packages” dialog, search the “Online” section for M:Science.

Step 4.
Install the “M:Science Web Services Client API” package

Step 5.
Use the client library from your code.

Example shown below in C#

var client = new MScience.Sms.SmsClient
{
    AccountId = "YourAccountId",
    Password = "YourPassword"
};
var sendResult = client.Send("+44123456789", "", "Hello world", 0, true);

Console.WriteLine(sendResult.Code);
if (sendResult.HasError)
{
    Console.WriteLine(sendResult.ErrorMessage);
}
else
{
    Console.WriteLine("Message Id {0}", sendResult.MessageId);
    Console.WriteLine("Balance {0}", sendResult.MessageBalance);
    Console.WriteLine("Pending : {0}", sendResult.PendingMessages);
    Console.WriteLine("Surcharge : {0}",  sendResult.SurchargeBalance);
    var status = client.GetMessageStatus(new[] { sendResult.MessageId });
    Console.WriteLine("Message Status Code = {0}, Status = {1}", 
                      status.First().Code, status.First().Status);
}

var deliveryReceipts = client.GetDeliveryReceipts();

if (deliveryReceipts.Length > 0)
{
    Console.WriteLine("Delivery Receipts:");
}

foreach (var deliveryReceipt in deliveryReceipts)
{
    Console.WriteLine(deliveryReceipt.Text);
}
Download Sample App
Back to top
STILL NOT SURE WHAT TO DO?

We are glad that you preferred to contact us. Please fill our short form and one of our friendly team members will contact you back.

Form is not available. Please visit our contact page.
X
CONTACT US