| |
 |
| |
ASP.NET Examples to Send SMS, Receive SMS. |
 |
| Introduction |
 |
This tutorial demostrates how it is
possible to write ASP.NET scripts/applications to send and
receive SMS using VisualGSM Enterprise Server.
We shall
go through 2 methods which you can use to send SMS through
VisualGSM Enterprise:
1). Execute an SQL statement to
insert the new message into VisualGSM LOGLOG table.
2).
Issue an HTTP GET to VisualGSM Enterprise CSEND web API.
VisualGSM Enterprise can forward received SMS messages
to your ASP.NET script via HTTP
GET.
Note:- For complete API
parameters, please refer to the VisualGSM Enterprise API Guide.
|
 |
| |
| Software Requirement |
 |
1). VisualGSM Enterprise Server (SMS
Gateway) 2). ASP.NET and IIS 5 (you may use higher
versions) 3). Sample ASP.NET scripts |
 |
| |
| Procedure |
 |
| Example 1:-
Creating an ASP.NET script to send SMS by executing an SQL
statement to insert the new message into VisualGSM LOGLOG
table. |
 |
1. Install VisualGSM Enterprise Server.
If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway Download). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server. |
 |
2.
ASP.NET/IIS environment.
If you do not
have ASP.NET/IIS running on your server, you may install IIS
from Add/Remove Programs in the control panel of Microsoft
Windows XP or higher. Choose Add/Remove Windows Components and
then select Internet Information Services. This will install
Mirosoft IIS on your PC and will create a folder Inetpub on
the root folder of your Windows installation drive.
If
Microsoft .NET SDK was installed before IIS then configure
ASP.NET for IIS by following steps given below: 1) Open
Command Prompt and change current directory to the .NET
framework directory that is present inside the Windows
installation directory. 2) Type following command and press
Enter: aspnet_regiis.exe
-i
Download the Sample ASP.NET Scripts and extract the folder
aspnet-samples and contents to c:\inetpub\wwwroot\. |
 |
3. Configure and run ASP.NET script.
There are 3 ASP.NET files,
(mssql_insert_db.aspx,mysql_insert_db.aspx,oracle_insert_db.aspx).
Select
the file which corresponds to the database you are using for
VisualGSM Enterprise and amend the parameter url, user and
password to your setup.
For example, for SQL Server, please configure
mssql_insert_db.aspx:
Dim url as String ="localhost" 'MSSQL host/ip
address. Dim user as String = "sa" Dim
pass="password"
After that, run mssql_insert_db.aspx from your web
browser: http://127.0.0.1/aspnet-samples/mssql_insert_db.aspx
Note:-Please amend
"127.0.0.1" to the address of your IIS server.
On success, you should get a return
message "Data Inserted Successfully!".
Note: If you encounter a database error, please troubleshoot using the following steps:
For
MSSQL:
i). Ensure that SQL Server service is
running and your url is correct.
Also ensure
that your MSSQL accepts TCP/IP connections. Run SVRNETCN.exe
in Bin folder of MSSQL. Select TCP/IP and Click on Enable.
Click OK and then restart SQL Server.
For
Oracle:
i). Ensure that Oracle is properly
installed.
ii) Ensure that the TNS Service Name that you provided
in url is working by using the tnsping utility that comes with
Oracle.
For MySQL:
i). Ensure that MySQL is properly
installed.
ii) Ensure that MySQL Connector 3.51 is also
installed.
|
 |
4. Start VisualGSM Service.
Start VisualGSM Service using the "Start" button on VisualGSM Enterprise Manager.
Note:- If VisualGSM service does not start, refer to
the returned message and check your setup. Refer to the next section,
troubleshooting.
Proceed with live SMS testing (see Step 3). Refer to the sms server log file for testing details. |
| |
| |
|
Example 2:- Using a ASP.NET script to send SMS by issuing an HTTP
GET to VisualGSM Enterprise CSEND web API. |
 |
|
1. Install VisualGSM Enterprise Server.
If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway Download). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server.
Note:-
For CSEND API to work, you must install and configure IIS (or Apache).
Please refer to the "Readme" and "QuickStart Checklist" files in your
VisualGSM Enterprise installer download. |
 |
2.
ASP.NET/IIS environment.
If you do not
have ASP.NET/IIS running on your server, you may install IIS
from Add/Remove Programs in the control panel of Microsoft
Windows XP or higher. Choose Add/Remove Windows Components and
then select Internet Information Services. This will install
Mirosoft IIS on your PC and will create a folder Inetpub on
the root folder of your Windows installation drive.
If
Microsoft .NET SDK was installed before IIS then configure
ASP.NET for IIS by following steps given below: 1) Open
Command Prompt and change current directory to the .NET
framework directory that is present inside the Windows
installation directory. 2) Type following command and press
Enter: aspnet_regiis.exe
-i
Download the Sample ASP.NET Scripts and extract the folder
aspnet-samples and contents to c:\inetpub\wwwroot\. |
   |
|
3. Open sendsms.aspx from
your browser.
Open sendsms.aspx using an
editor or Notepad, and change the value of url string to the
URL of CSEND API (csend.exe or csend.dll) on your VisualGSM
Enterprise Server.
For example:
Dim
url="http://127.0.0.1/cgi-bin/csend.exe"
After
that, open sendsms.aspx from your
browser.
Note:- If you encounter an
error, please check if you have configured the permissions on
your IIS (refer to "QuickStart Checklist").
|
 |
4. Start VisualGSM Service.
Start VisualGSM Service using the "Start" button on VisualGSM Enterprise Manager.
Note:- If VisualGSM service does not start, refer to
the returned message and check your setup. Refer to the next section,
troubleshooting.
Proceed with live SMS testing (see Step 3). Refer to the sms server log file for testing details. |
| |
| |
| Example 3:-
Setting up VisualGSM Enterprise to forward received SMS
messages to your ASP.NET application via HTTP
GET. |
 |
|
1. Install VisualGSM Enterprise Server.
If you have not installed VisualGSM Enterprise Server, you can download the installers from this link (VisualGSM SMS Gateway Download). Refer to the "Quick Start Checklist" on how to configure VisualGSM Enterprise Server. |
 |
2.
ASP.NET/IIS environment.
If you do not
have ASP.NET/IIS running on your server, you may install IIS
from Add/Remove Programs in the control panel of Microsoft
Windows XP or higher. Choose Add/Remove Windows Components and
then select Internet Information Services. This will install
Mirosoft IIS on your PC and will create a folder Inetpub on
the root folder of your Windows installation drive.
If
Microsoft .NET SDK was installed before IIS then configure
ASP.NET for IIS by following steps given below: 1) Open
Command Prompt and change current directory to the .NET
framework directory that is present inside the Windows
installation directory. 2) Type following command and press
Enter: aspnet_regiis.exe
-i
Download the Sample ASP.NET Scripts and extract the folder aspnet-samples and contents to c:\inetpub\wwwroot\. |
 |
|
3. Following that, create
the HTTP type keyword to forward received SMSes to
sms2aspnet.aspx.
Run VisualGSM Enterprise
Manager, and click on "Keyword" tab.
Scroll through
the table and select the keyword with the name "NOKEYWORD".
Click on "Edit ", change the Type to "HTTP URL" (refer to the
below screen capture for details).
Please set URL
as:
Note:-Please amend
"127.0.0.1" to the address of your IIS server.
Set
Parameter as:
Click on the TEST button to simulate the Keyword Action.
|
 |
 |
 |
 |
|
5. Start VisualGSM Service and test your new setup.
Start VisualGSM Service using the "Start" button on VisualGSM Enterprise Manager.
Send some SMSes to your VisualGSM Enterprise Server - you should receive a response SMS similar to the following example:
PhoneNumber:+6590601300
Keyword:Hello
Message:World
Modem Port:COM4
COMMMETHOD:
SMSC Number:
DB Seqno:1255491
Sendfrom:
Note:- If VisualGSM service does not start, refer to
the returned message and check your setup. Refer to the next section,
troubleshooting.
Proceed with live SMS testing (see Step 3). Refer to the sms server log file for testing details. |
 |
6. Redirecting received SMS to another recipient or group of users.
If you need to redirect received SMS to another recipient or group of
users, please amend sms2aspnet.aspx to the following (Note: The following
example is for MySQL).
To use, send the following message to the SMS Gateway:
[Recipient-Group] Hi, how are you!
Replace [Recipient-Group] with your recipient/group name.
|
<%
Response.Write("Thank you, your message
has been forwarded to Group:" &
Request.Params("KEYWORD")
Dim connection as OdbcConnection =
GetConnection("url", "user","pass") 'Replace url, user,
and pass with appropriate values
Dim destination as String =
Request.Params("KEYWORD")
Dim content as String =
Request.Params("M") & "- SMS forwarding service from
Visualtron"
content= content.Substring(0,160)
'limits the redirected SMS to a maximum of 1 SMS
length.
Dim command as OdbcCommand
Try
connection.Open() 'Open the
connection
command = connection.CreateCommand()
'Create Command object to execute any type of SQL
command.CommandText = "INSERT INTO
LOGLOG (DESTINATION,CONTENT ) VALUES ('" &
destination & "','" & content & "')"
comm.ExecuteNonQuery() 'Run the
SQL and insert the message details into DB
Response.Write("Data Inserted
Successfully!")
Finally
End Try
%> |
|
 |
| |
|
 |
| |
| Troubleshooting |
 |
If you are facing any issues, please refer to the sms_server_log.txt file for logging details.
Default path for sms server log:
c:\Program Files\Visualtron Software Corporation\VisualGSM\vgsmlog\sms_server_log.txt
If you have any questions or comments, you may post on the support forum for this tutorial - click here. |
| |
 |
| |
| Relevant links |
Java Examples to Send SMS, Receive SMS.
PHP Examples to Send SMS, Receive SMS.
Send SMS from Outlook (Via Exchange Server or Lotus Notes using POP3)
Send an SMS via email Demo
Build an SMS Directory Bot in just 4 hrs (including testing)
How to configure Microsoft Exchange SMTP Connector to send SMS
VisualGSM Enterprise API Guide |
| |
| |
| |