How can use sms api in C#

Just create SMS class object and pass value of mobile number and message in SendSMS number.
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.VisualBasic;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;

public class sms
{
    public void SendSMS(string mobile_Number, string Message)
    {
        string text = ConvertStringIntoURLFormat(Message);
        string mobileno = ConvertSeprateComma(mobile_Number);
        string strPushURL= "http://alerts.sinfini.com/api/web2sms.php?workingkey=XXXXXXXXXXXXXXXX&sender=XXXXXX&to=" + mobileno + "&message=" + text;
        WebRequest webrequest = WebRequest.Create(strPushURL);
        WebResponse response = webrequest.GetResponse();
        Stream ReceiveStream = response.GetResponseStream();
        StreamReader readStream = new StreamReader(ReceiveStream);
        string strResponse = readStream.ReadToEnd();
        GetResponse(strResponse);
        //return ("sucess");
    }


    private string ConvertStringIntoURLFormat(string SenderID)
    {
        string senderid = "";
        string retstring = "";
        char[] s = SenderID.ToCharArray();
        for (int ind = 0; ind < s.Length; ind++)
        {
            if (Convert.ToInt32(s[ind]) == 13)
            {
                senderid = senderid + "\n";
            }
            else
            {
                senderid = senderid + SenderID.Substring(ind, 1);
            }
        }

        retstring = senderid.Replace("%", "%25");
        retstring = retstring.Replace("'", "%60");
        retstring = retstring.Replace("~", "%7E");
        retstring = retstring.Replace("\"", "%22");
        retstring = retstring.Replace("+", "%2B");
        retstring = retstring.Replace("^", "%5E");
        retstring = retstring.Replace("{", "%7B");
        retstring = retstring.Replace("}", "%7D");
        retstring = retstring.Replace(@"\", "%5C");
        retstring = retstring.Replace("|", "%7C");
        retstring = retstring.Replace("[", "%5B");
        retstring = retstring.Replace("]", "%5D");
        retstring = retstring.Replace(",", "%2C");
        retstring = retstring.Replace("`", "%60");
        retstring = retstring.Replace(" ", "%20");
        retstring = retstring.Replace("$", "%24");
        retstring = retstring.Replace("&", "%26");
        retstring = retstring.Replace("@", "%40");
        retstring = retstring.Replace("?", "%3F");
        retstring = retstring.Replace(":", "%3A");
        retstring = retstring.Replace(";", "%3B");
        retstring = retstring.Replace("<", "%3C");
        retstring = retstring.Replace(">", "%3E");
        retstring = retstring.Replace("#", "%23");
        return retstring;
    }

    private string ConvertSeprateComma(string mobile)
    {
        string mobileno = "";
        string[] arrmobile = mobile.Split(',', ' ', '\n');
        for (int i = 0; i < arrmobile.Length; i++)
        {
            mobileno += arrmobile[i] + ",";
        }
        mobileno = mobileno.TrimEnd(',');
        return mobileno;
    }


    private void GetResponse(string strResponse)
    {
        int count = 0;
        // string strResponse = "\nNDNC Number\n<br/>\nNDNC Number\n<br/>Message sent!!!!!Your Transaction Id- 4049969\n<br/>\nNDNC Number\n<br/>\nNDNC Number\n<br/>\r\n\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n\r\n<html xmlns=\"http://ww...";
        strResponse = strResponse.Replace("\n", "");
        strResponse = strResponse.Replace("<br/>", ",");
        string[] word1 = strResponse.Split(',');

        for (int i = 0; i < word1.Length; i++)
        {
            if (word1[i].ToString() == "NDNC Number")
            {
                count = count + 1;
            }
        }
        strResponse = strResponse.Replace("NDNC Number,", "");
        string[] word = strResponse.Split('\r', '<', ',');
        if (count > 0)
        {
            //lblTransactionId.Text = "" + word[0].ToString() + " NDNC Numbers= " + count + "";
        }
        else
        {
            // lblTransactionId.Text = word[0].ToString();
        }

        //lblTransactionId.Visible = true;
    }





}

Share on facebook Google Twitter

Web Engineers here !


Grideb is the group of engineers who provide excellent solution for domain scenario with experienced, talented and high skilled engineers. We work hard to reduce complication of user interface and improve better quality of service.

-- Chief Executive Officer, GRIDEB SERVICES


www.grideb.com

Contact Us

GRIDEB SERVICES
Office-1,FF ,One Square Office Mall
Shaktikhand-III,Indirapuram,Ghaziabad
Uttar Pradesh 201004 (INDIA)
P: +91 (120) 260-6044
M: +91 90-1300-3421
Email ID
info@grideb.com




Grideb Services 2013-2014