Welcome to Dream.In.Code
Become an Expert!

Join 149,594 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,857 people online right now. Registration is fast and FREE... Join Now!




Sms

 
Reply to this topicStart new topic

Sms, Sms Code

charan
5 Oct, 2007 - 12:03 AM
Post #1

New D.I.C Head
*

Joined: 4 Oct, 2007
Posts: 3


My Contributions
Can anyone help in writing the code for sending sms and receiving Sms for an smscontest
How to start the code.

This post has been edited by charan: 5 Oct, 2007 - 09:20 PM
User is offlineProfile CardPM
+Quote Post

Chubber
RE: Sms
31 Oct, 2007 - 09:54 AM
Post #2

D.I.C Head
Group Icon

Joined: 16 Oct, 2006
Posts: 118


Dream Kudos: 225
My Contributions
Well, sending shouldn't be too hard. It is just an SMTP message sent to an email address. But collecting it would be quite a bit harder. Can you get your SMS account to forward copies to an email account somehow?
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Sms
31 Oct, 2007 - 10:46 AM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,482



Thanked: 161 times
Dream Kudos: 9050
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Actually sending an SMS is a little complicated than Chubber eluded too. Yes, for some carriers sending an SMS message can be an SMTP message, but that only applies to a few carriers, which will limit the ones who can use your service, which I imagine isn't the way you want to go. Ive been doing some work on the same issue using the SMS.dll available in Windows Mobile (but that dll isn't offered in any other version of Windows unfortunately)

The only other option is to use an SMS gateway service, some are free, others charge (do a Google search for SMS Gateways), or limit the people who can use your service to those that have carriers that use simple SMTP messages
User is offlineProfile CardPM
+Quote Post

milind_kansagara@hotmail.com
RE: Sms
7 Dec, 2007 - 01:29 AM
Post #4

New D.I.C Head
*

Joined: 7 Dec, 2007
Posts: 1


My Contributions
Do you have any list of gateways that are free. I have some code for sending sms but i am confused in receiving sms so please send me code on milind_kansagara@hotmail.com....
User is offlineProfile CardPM
+Quote Post

pemmasanikrishna
RE: Sms
16 Dec, 2007 - 09:35 PM
Post #5

New D.I.C Head
*

Joined: 16 Dec, 2007
Posts: 2



Thanked: 1 times
My Contributions


Private Sub SMSSending(ByVal SmsContent As String, ByVal Mobileno As Int64)
Try
If SmsContent.Length > 155 Then
SmsContent = SmsContent.Substring(0, 150)
End If
Dim client As WebClient = New WebClient
Dim IDStatus As String
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
client.QueryString.Add("user", "pemmasani")
client.QueryString.Add("password", "0123456")
client.QueryString.Add("api_id", "012345")
client.QueryString.Add("to", Mobileno)
client.QueryString.Add("text", SmsContent)
Dim baseurl As String = "http://api.clickatell.com/http/sendmsg"
Dim data As Stream = client.OpenRead(baseurl)
Dim reader As StreamReader = New StreamReader(data)
Dim s As String = reader.ReadToEnd()
data.Close()
reader.Close()
IDStatus = s.Substring(0, 2)
'IDStatus = "ID"
If IDStatus = "ID" Then
Label1.Text = "ok"
End If

Catch ex As Exception
Response.Write(ex.Message)
Exit Sub






------------------------------------------------------



Private Sub SendSMS()
Try
'UpdateOldNewsStatus()
Dim str As String
Dim Count As Int64
Dim da As New SqlDataAdapter
Dim subDs As New DataSet
'Dim cnn As New SqlConnection(dbname)
str = "select * from cnn"
da.SelectCommand = New SqlCommand(str, cnn)
da.Fill(subDs, "table1")
Count = subDs.Tables("table1").Rows.Count
Dim i, j, z, subi, smsi As Int64
Dim Userid, SubCode, SMSContent As String
Dim MobileNo As Int64
i = subDs.Tables("table1").Rows.Count - 1
If Count > 0 Then
For i = 0 To Count
Userid = subDs.Tables("table1").Rows(i)("Username")
MobileNo = subDs.Tables("table1").Rows(i)("PhoneNo")
str = "select * from SubscribedGames where UserId='" & Userid & "'"
If i > 0 Then
subDs.Tables("SubGames").Clear()
End If
da.SelectCommand = New SqlCommand(str, cnn)
da.Fill(subDs, "SubGames")
subi = subDs.Tables("SubGames").Rows.Count
For j = 0 To subi - 1
SubCode = subDs.Tables("SubGames").Rows(j)("SubScribedGame")
If j > 0 Then
subDs.Tables("News").Clear()
End If
str = "select * from news where Category='" & SubCode & "' and status='New'"
da.SelectCommand = New SqlCommand(str, cnn)
da.Fill(subDs, "News")
smsi = subDs.Tables("News").Rows.Count
For z = 0 To smsi - 1
SMSContent = subDs.Tables("News").Rows(z)("Header")
SMSSending(SMSContent, MobileNo)

Next
Next
Next
UpdateOldNewsStatus()
End If



---------------------------------------------------------------------


Private Sub UpdateOldNewsStatus(ByVal Category As String)
'Dim cnn As New SqlConnection(dbname)
Dim cmd As SqlCommand
Dim str As String
If cnn.State = ConnectionState.Open Then
cnn.Close()
End If
cnn.Open()
str = "update News set status='Old' where Category='" & Category & "'"
cmd = New SqlCommand(str, cnn)
cmd.ExecuteScalar()
cnn.Close()
End Sub
Private Sub UpdateOldNewsStatus()
Dim cmd As SqlCommand
Dim str As String
If cnn.State = ConnectionState.Open Then
cnn.Close()
End If
cnn.Open()
str = "update News set status='Old'"
cmd = New SqlCommand(str, cnn)
cmd.ExecuteScalar()
cnn.Close()
End Sub


bye....
Pemmasani....
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 11:20PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month