Before going through the code, here are some details, you need to understand.
Just like sending email, you need a SMTP, for SMS you need a SMPP. SMPP - Short Message Peer-to-Peer protocol is a telecommunications industry protocol for exchanging SMS messages. Now for individuals, it is not possible to afford SMPP server, so here goes the SMS Service Provider. Though most of the SMS Service providers are fake and work just as a reseleer under a Real Service Provider(have integrated SMPP).
The code is very straight forward. Most of the cases, you need to do HTTP Post.
So, no particular code will help you. First select the Service Provider and buy some credits and they will provide you the sample code.
Here is a sample code works with most of the Service Provider,
string senderusername = "xxxxx";
string senderpassword = "xxxx";
string senderid = "xxx";
string sURL;
StreamReader objReader;
sURL = "service provider url with username,password,senderid,messagetext,tomobile and others passed as querysrring";
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
try
{
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
objReader = new StreamReader(objStream);
objReader.Close();
}
catch (Exception ex)
{
ex.ToString();
}
Hope this clears you.
cheers