Tuesday, 3 September 2013

Sending SMS Via PC (VB6)

(VB sms application with source code. Mobile/USB connection. AT command for sending SMS.)
Private Sub cmdSend_Click()
 With MSComm1
        .CommPort = Val(Trim(txtPortNo))
        .Settings = "9600,N,8,1"
        .Handshaking = comRTS
        .RTSEnable = True
        .DTREnable = True
        .RThreshold = 1
        .SThreshold = 1
        .InputMode = comInputModeText
        .InputLen = 0
        .PortOpen = True 'must be the last
End With
' Send an 'AT' command to the phone
MSComm1.Output = "AT" & vbCrLf
Sleep 500
MSComm1.Output = "AT+CMGF=1" & vbCrLf           'Set Modem always in Text Mode...
Sleep 500
MSComm1.Output = "AT+CMGS=" & Chr(34) & TxtNumber.Text & Chr(34) & vbCrLf
Sleep 1000
MSComm1.Output = TxtMessage.Text & Chr(26)
Sleep 2000

Dim Result As String
Result = MSComm1.Input

If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
End If

    MsgBox "Message Send" & Result

End Sub

No comments:

Post a Comment