C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » ASP.NET WebForms »

Sending SMS Through .NET


Posted Date: 02 Jul 2009    Resource Type: Code Snippets    Category: ASP.NET WebForms
Author: ManigandanMember Level: Gold    
Rating: 1 out of 5Points: 7



HI,

Here i have submitted an article for sending SMS through .NET(VB) application.

The SMS and MMS Toolkit is a software development kit (SDK) to enhance an application or script with SMS, MMS and Pager functionality. SMS messages can be sent using a GSM/GPRS modem, an SMPP provider, an HTTP compliant SMS provider or using a standard dialup or fixed-line SMS modem. MMS messages can be sent via a GSM/GPRS modem (MM1), an SMTP server (MM4) or an XML/SOAP compliant provider (MM7).

SMS Features:



•Send and receive numeric- and alphanumeric text SMS messages
•Verify delivery of outgoing SMS messages
•Support for multimedia SMS messages, including ringtones, pictures and logo's
•Support for WAP Push, WAP Bookmarks, vCards, voicemail/e-mail/fax/MMS indications
•Support for Unicode, to support foreign languages like Arabic, Chinese, Turkisch, etc.
•Support for multi-part messages, to allow messages longer than 160 characters
•Support for GSM modems, GSM phones, SMS/HTTP providers, SMPP (Short Message Peer to Peer) providers, TAP/XIO and UCP dial-in SMSC providers
•Support Multi-threading environments. The component is thread-safe, which means it can be used in a multi-threaded environment
•Samples included for various development platforms: MS Visual Basic, MS Visual Basic .NET, MS Visual C++, MS Visual Studio C# .NET, ASP, ASP .NET, Borland Delphi, Borland C++ Builder, ColdFusion and more.

MMS Features:



•Support for many multimedia formats incl.: JPG, GIF, PNG, BMP, WBMP, TIF, WAV, MP3, MIDI, AC3, GP3, AVI, MPG, MP4, VCARD, VCALENDAR, JAR and more.
•Support for MM1 (MMS over WAP), MM4 (MMS over SMTP) and MM7 (MMS over HTML/SOAP).


Thing to do:
1.Download and install the SMS and MMS Toolkit
2.Create a new ASP .NET VB Project
3.Refer to the SMS and MMS Toolkit Library
MMS toolkit namespace is,

Imports AXmsCtrl

4.Declare and create the SMPP object
You have to declare and Create the Objects like,


Private objSmppProtocol As SmsProtocolSmpp
Private objSmsMessage As SmsMessage
Private objSmsConstants As SmsConstants

objSmppProtocol = New SmsProtocolSmpp()
objSmsMessage = New SmsMessage()
objSmsConstants = New SmsConstants()


Finally,
5.Send and/or receive SMS messages:
In webform,

Imports AXmsCtrl
//importing mms file
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents Text1 As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents TextMessage As System.Web.UI.HtmlControls.HtmlTextArea
Protected WithEvents CheckboxUnicode As System.Web.UI.HtmlControls.HtmlInputCheckBox
Protected WithEvents Submit As System.Web.UI.HtmlControls.HtmlInputButton
Protected WithEvents TextRecipient As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents TextResult As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents Form As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents TextReference As System.Web.UI.HtmlControls.HtmlInputText

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region



Public objSmppProtocol As SmsProtocolSmpp
Public objSmsMessage As SmsMessage
Public objSmsConstants As SmsConstants



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objSmppProtocol = New SmsProtocolSmpp()
objSmsMessage = New SmsMessage()
objSmsConstants = New SmsConstants()
End Sub



Private Sub Submit_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.ServerClick
Dim strReference as String

objSmppProtocol.Server = "smpp.activexperts-labs.com"
objSmppProtocol.ServerPort = 2775
objSmppProtocol.SystemID = "AX008"
objSmppProtocol.SystemPassword = "812056"
objSmppProtocol.SystemType = "SMPP"
objSmppProtocol.ServerTimeout = 10000
objSmppProtocol.SystemMode = objSmsConstants.asSMPPMODE_TRANSMITTER
objSmppProtocol.LogFile = "C:\\SmsLogAsp.txt"

objSmsMessage.Recipient = TextRecipient.Value
objSmsMessage.Data = TextMessage.Value

If (CheckboxUnicode.Checked = True) Then
objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_UNICODE
Else
objSmsMessage.Format = objSmsConstants.asMESSAGEFORMAT_TEXT
End If

Submit.Disabled = True

objSmppProtocol.Connect()

Submit.Disabled = False

If (objSmppProtocol.LastError <>0) Then
TextResult.Value = "ERROR #" & objSmppProtocol.LastError & " (" & objSmppProtocol.GetErrorDescription(objSmppProtocol.LastError) & ")"
Exit Sub
End If

Submit.Disabled = True

strReference = objSmppProtocol.Send( objSmsMessage )

Submit.Disabled = False

If (objSmppProtocol.LastError <> 0) Then
TextResult.Value = "ERROR #" & objSmppProtocol.LastError & " (" & objSmppProtocol.GetErrorDescription(objSmppProtocol.LastError) & ")"
TextReference.Value = ""
Else
TextResult.Value = "SUCCESS"
TextReference.Value = strReference
End If

objSmppProtocol.Disconnect()
End Sub
End Class



Now in Webform.aspx,

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="SendSms.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ActiveXperts SMS and MMS Toolkit ASP.NET Sample (VB)</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<font face="sans-serif" size="2">
<hr size="1" color="#707070">
<h2>ActiveXperts SMS and MMS Toolkit ASP.NET Sample (VB)</h2>
<h3>Send an SMS message to a recipient through an SMPP provider.</h3>
IMPORTANT: For more details about using SMS and MMS Toolkit with ASP.NET: <a href="http://www.activexperts.com/support/xmstoolkit/#aspnet" target="_blank">
SMS and MMS Toolkit ASP.NET FAQ</a>.
<hr size="1" color="#707070">
<br>
<form id="Form" method="post" runat="server">
<table border="0" bgcolor="#f0f0f0">
<tr>
<td valign="top">Recipient:</td>
<td><input size="50" type="text" value="<enter recipient number>" id="TextRecipient" runat="server"></td>
</tr>
<tr>
<td valign="top">Message:<br>(max. 160 chars)</td>
<td><textarea rows="3" cols="65" id="TextMessage" runat="server">Hello, world</textarea></td>
</tr>
<tr>
<td valign="top"> </td>
<td><input type="checkbox" id="CheckboxUnicode" runat="server">Send message as Unicode</td>
</tr>
<tr>
<td valign="top">Result: </td>
<td><input size="50" type="text" id="TextResult" runat="server"></td>
</tr>
<tr>
<td valign="top">Message Reference: </td>
<td><input size="50" type="text" id="TextReference" runat="server"></td>
</tr>
</table>
<br>
<hr size="1" color="#707070">
<br>
<input type="submit" value="Send Message" id="Submit" runat="server">
<br>
<br>
<hr size="1" color="#707070">
</form>
</font>
</body>
</html>



So far we have seen the step to send the SMS through VB.NET,
You can able to sent Text Messages and Pictures Messages through this Coding.




Thanks,
Mani

Attachments






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Sending SMS through VB.NET  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Bind the xml values to Gridview using asp.net
Previous Resource: Dynamic DataGrid
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET WebForms


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use