ASP.NET

ASP.NET SMS API Wrapper

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

Step 1.
Create a new ASP.NET 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#. Also available in Visual Basic

Dim client As New SmsClient()
client.AccountId = "YourAccountId"
client.Password = "YourPassword"
 
Dim sendResult As SendResult = client.Send("+44123456789", "",
                                           "Hello world", 0, True)
 
Console.WriteLine(sendResult.Code)
 
If (sendResult.HasError) Then
    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)
 
    Dim status As StatusResult()
    status = client.GetMessageStatus({sendResult.MessageId})
 
    Console.WriteLine("Message Status Code = {0}, Status = {1}",
                      status.First().Code, status.First().Status)
End If
 
Dim deliveryReceipts As InboundMessageResult()
deliveryReceipts = client.GetDeliveryReceipts()
 
If (deliveryReceipts.Length > 0) Then
    Console.WriteLine("Delivery Receipts:")
End If
 
For Each deliveryReceipt As InboundMessageResult In deliveryReceipts
    Console.WriteLine(deliveryReceipt.Text)
Next
Download Sample App
Back to top