Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

VB how to send long SMS using VB.net, send SMS using VB.net

views
     
TSmasaemas123
post Nov 15 2014, 03:22 PM, updated 12y ago

New Member
*
Newbie
2 posts

Joined: Sep 2014


hi
can anyone help me to make code below send long SMS

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sub SendSMS()

If Modem.IsOpen = False Then
MsgBox("Port not Open!!")
Exit Sub
End If
If Me.TxtTo.Text = "" Then
MsgBox("No recepient number!!")
Exit Sub

End If

If Me.TxtSMS.Text = "" Then
MsgBox("Blank text message are not allowed!!")
Exit Sub

End If

sendbutton.Enabled = False
Sending = True
SendAttempt = 0
Do
ATSend("AT+CMGF=1")
Result = ATRead(1000)
Loop While Result.Contains("COMMAND NOT SUPPORT")
Do
ATSend("AT+CSMP=17,167,0,0")
Result = ATRead(1000)
Loop While Result.Contains("COMMAND NOT SUPPORT")
Do
Do
ATSend("AT+CMGS=""" & TxtTo.Text & """")
Result = ATRead(1000)
Loop While Result.Contains("COMMAND NOT SUPPORT")
ATSend(TxtSMS.Text & Char.ConvertFromUtf32(26) & vbCr)
'ATSend(MyMessage & Char.ConvertFromUtf32(26) & vbCr)
'ATSend(MyMessage & vbCrLf & Chr(26))

Result = ATRead(10000)
SendAttempt += 1
Loop While Result.Contains("COMMAND NOT SUPPORT") Or (Result.Contains("ERROR") And SendAttempt < 5)
If Result.EndsWith(vbCrLf & "OK" & vbCrLf) Then
TxtSMS.Text = ""
TxtTo.Text = ""
' MsgBox("Message Successfully Sent")
Else
' MsgBox("Message Could Not Be Sent", MsgBoxStyle.Critical, "Error")
End If
sendbutton.Enabled = True
Sending = False


End Sub
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

please help. rclxub.gif rclxub.gif rclxub.gif
blackstar88
post Nov 17 2014, 09:11 AM

Casual
***
Junior Member
424 posts

Joined: Apr 2013
QUOTE(masaemas123 @ Nov 15 2014, 03:22 PM)
hi
can anyone help me to make code below send long SMS

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sub SendSMS()

If Modem.IsOpen = False Then
MsgBox("Port not Open!!")
Exit Sub
End If
If Me.TxtTo.Text = "" Then
MsgBox("No recepient number!!")
Exit Sub

End If

If Me.TxtSMS.Text = "" Then
MsgBox("Blank text message are not allowed!!")
Exit Sub

End If

sendbutton.Enabled = False
Sending = True
SendAttempt = 0
Do
ATSend("AT+CMGF=1")
Result = ATRead(1000)
Loop While Result.Contains("COMMAND NOT SUPPORT")
Do
ATSend("AT+CSMP=17,167,0,0")
Result = ATRead(1000)
Loop While Result.Contains("COMMAND NOT SUPPORT")
Do
Do
ATSend("AT+CMGS=""" & TxtTo.Text & """")
Result = ATRead(1000)
Loop While Result.Contains("COMMAND NOT SUPPORT")
ATSend(TxtSMS.Text & Char.ConvertFromUtf32(26) & vbCr)
'ATSend(MyMessage & Char.ConvertFromUtf32(26) & vbCr)
'ATSend(MyMessage & vbCrLf & Chr(26))

Result = ATRead(10000)
SendAttempt += 1
Loop While Result.Contains("COMMAND NOT SUPPORT") Or (Result.Contains("ERROR") And SendAttempt < 5)
If Result.EndsWith(vbCrLf & "OK" & vbCrLf) Then
TxtSMS.Text = ""
TxtTo.Text = ""
' MsgBox("Message Successfully Sent")
Else
' MsgBox("Message Could Not Be Sent", MsgBoxStyle.Critical, "Error")
End If
sendbutton.Enabled = True
Sending = False
End Sub
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

please help. rclxub.gif  rclxub.gif  rclxub.gif
*
what is the problem with you code? seems like ok to me
if message.length > max_amount_of_word_to_send then
'split the message into 2 sms?
end if
like this?
TSmasaemas123
post Nov 17 2014, 09:22 AM

New Member
*
Newbie
2 posts

Joined: Sep 2014


QUOTE(blackstar88 @ Nov 17 2014, 09:11 AM)
what is the problem with you code? seems like ok to me
if message.length > max_amount_of_word_to_send then
'split the message into 2 sms?
end if
like this?
*
i want to send sms more than 160 character
and the recipient receive as/only 1 message
blackstar88
post Nov 17 2014, 09:51 AM

Casual
***
Junior Member
424 posts

Joined: Apr 2013
QUOTE(masaemas123 @ Nov 17 2014, 09:22 AM)
i want to send sms more than 160 character
and the recipient receive as/only 1 message
*
ya.. becoz sms got limit.. like when u send with your phone also, after certain amount of characters, it will charge extra on you...

so in ur case u need to split the message into few if it is too long and then send multiple times..

something like this:
dim maxlength as integer
dim message as string
again:
i = len(message)
if i > maxlength then
message_frontpart = left(message, maxlength)
message = right(message, i-maxlength)
'send message_frontpart
goto again

else
'send message
end if



loop is better compare to using goto, as i simply type out here
hope this will help





narf03
post Nov 17 2014, 10:09 AM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


160 characters without unicode, i think about 100 with unicode. if exceed, split into multiple sms.

This post has been edited by narf03: Nov 17 2014, 10:09 AM

 

Change to:
| Lo-Fi Version
0.0141sec    0.54    5 queries    GZIP Disabled
Time is now: 20th December 2025 - 02:39 PM