|
Back

Send an SMS with TextAnywhere Using C# and ASP.net
I was tasked with sending SMS via an ASP.net web page using my chosen language of C#. The client had an existing account using a company called TextAnywhere, but I couldn't find any examples on their web site using C#, only in VB.
TextAnywhere uses the SOAP standard to enable you to send SMS messages. You can view their SOAP specification here.
In order to send the SMS you must first get hold of the Microsoft SOAP library and install it on your web server. If you haven't got access to do this you will have a problem. You can download the necessary install here.
To then send SMS via your web site use the following code.
First making sure you are including the relevant libraries by putting the following at the top of your code file.
using MSSOAPLib30;
using System.Reflection;
Then using the following code to make the SOAP request and send your SMS!
SoapClient30 sc = new SoapClient30();
sc.MSSoapInit("http://ws.textanywhere.net/ta_SMS.asmx?wsdl", "", "", "");
Type type = sc.GetType();
object[] args = {
"YOURCLIENTID", // your client id
"YOURCLIENTPASSWORD", // your client password
"CLIENTREF", // client ref - unique message reference
"BILLINGREF", // billing ref
"2", // connection - 1=test, 2=low volume, 4=high volume
"ORIGINATOR", // originator
1, // originator type ie 0=number or 1=letters
"07947123456",// desintation number
"Hi", //message
0, // sms type always 0
0 // sms encoding always 0
};
object ox = type.InvokeMember("SendSMS", BindingFlags.InvokeMethod, null, sc, args);
Label1.Text = ox.ToString();
Back
|