public static void Main()
string MyPassword = "sa%55pk";
string Masking = "SMS as";
string MessageText = "SMS Sent using .Net";
string jsonResponse = SendSMS(Masking, toNumber, MessageText, MyUsername, MyPassword);
Console.Write(jsonResponse);
public static string SendSMS(string Masking, string toNumber, string MessageText, string MyUsername, string MyPassword)
String URI = "http://Lifetimesms.com" + "/plain?" + "username=" + MyUsername + "&password=" + MyPassword + "&from=" + Masking + "&to=" + toNumber + "&message=" + Uri.UnescapeDataString(MessageText);
WebRequest req = WebRequest.Create(URI);
WebResponse resp = req.GetResponse();
var sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
var httpWebResponse = ex.Response as HttpWebResponse;
if (httpWebResponse != null)
switch (httpWebResponse.StatusCode)
case HttpStatusCode.NotFound:
return "404:URL not found :" + URI;
case HttpStatusCode.BadRequest:
return "400:Bad Request";
return httpWebResponse.StatusCode.ToString();