SMS IN ASP.NET

SEND SMS IN ASP.NET

DOWNLOAD SOURCE HERE

Introduction:

In this article we will see how to send sms from our web application using ozeki-Ng-SMS-Getway.

Pre-Requesite:

1) For sending sms from our asp.net web application we required third party sms-getway which will deliver our messages to user. You can download this Getway from here http://www.ozekisms.com/index.php?owpn=112.

2) Mobile Phone whith SIM card and Datacable. Which will be used for sending our sms.

Description:

Generally for sending Mail messages from our asp.net application we need the SMTP server which will deliver our mails. Same like this for sending SMS from asp.net  we need SMPP server which will deliver our messages to user. This getway is not a free software it’s paid software but for testing you can get 20 day’s trial edition. From here http://www.ozekisms.com/index.php?owpn=112.

Configuring SMS Getway:

After instalation of oseki-ng we have to configure the setting we need. Follow the follwing step to configure.

1)      Run the ozeki-ng which is runnig on default http://127.0.0.1:9501/

2)      Login with standerd user Admin and 123 pwd.

3)      On left hand side upper corner select the Service provider Connection as shown in digrame.

4)      Select GSM/GPRS modem connection. Before starting this step just connect your Mobile/Modem to system and then click on install. Ozeki-Ng automaticlly search your modem and will install the modem. Now we have done almost sending sms setting for ozeki-ng.

5)      You can add the different user also for that refere this link http://www.ozekisms.com/index.php?owpn=164&info=SQL_sms_example.

Now we are ready to send the sms. We will move to some steps to connect with this ozeki-ng sms getway from our asp.net application.

Using Coading:

1)      Create your asp.net website in C#.

2)      Design the send sms page like bellow.

3)      Write the following code in sentbutton_click event.

protected void btnsend_Click(object sender, EventArgs e)

{

try

{

if (txtmono.Text!=String.Empty && txtmsg.Text!=String.Empty)

{

SendMessage();

txtmono.Text = String.Empty;

txtmsg.Text = String.Empty;

lblmsg.Visible = true;

lblmsg.Text = “Message Sented”;

}

else

{

lblmsg.Visible = true;

lblmsg.Text = “Not Sented”;

}

}

catch (Exception)

{

throw;

}

}

private void SendMessage()

{

string _msg = txtmsg.Text;

//we creating the necessary URL string:

string ozSURL = “http://127.0.0.1”; //where Ozeki NG SMS Gateway is running

string ozSPort = “9501”; //port number where Ozeki NG SMS Gateway is listening

string ozUser = HttpUtility.UrlEncode(“admin”); //username for successful login

string ozPassw = HttpUtility.UrlEncode(“abc123”); //user’s password

string ozMessageType = “SMS:TEXT”; //type of message

string ozRecipients = HttpUtility.UrlEncode(“+91” + txtmono.Text); //who will get the message

string ozMessageData = HttpUtility.UrlEncode(_msg); //body of message

string createdURL = ozSURL + “:” + ozSPort + “/httpapi” +

“?action=sendMessage” +

“&username=” + ozUser +

“&password=” + ozPassw +

“&messageType=” + ozMessageType +

“&recipient=” + ozRecipients +

“&messageData=” + ozMessageData;

HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(createdURL);

//Get response from Ozeki NG SMS Gateway Server and read the answer

HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();

System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());

string responseString = respStreamReader.ReadToEnd();

respStreamReader.Close();

myResp.Close();

}

Conclusion:

In this way you can implement the sms sending facility in your asp.net web site. It’s very easy to implement and manage.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s