[英]Sending SMS through GSM modem to mobile phone
Using VB.NET I need to send a SMS using GSM modem to a mobile phone.使用 VB.NET 我需要使用 GSM 调制解调器向手机发送短信。
Currently I have the following code:目前我有以下代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If serialport.IsOpen Then
serialport.Close()
End If
Try
With serialport
.PortName = ComboBox1.Text
.BaudRate = 96000
.Parity = Parity.None
.DataBits = 8
.StopBits = StopBits.One
.Handshake = Handshake.RequestToSend
.DtrEnable = True
.RtsEnable = True
.NewLine = vbCrLf
End With
serialport.Open()
Catch ex As Exception
End Try
serialport.WriteLine("AT+CMGF=1" & vbCr)
System.Threading.Thread.Sleep(200)
serialport.WriteLine("AT+CMGS=" & Chr(34) & "destination" & Chr(34) & vbCr)
System.Threading.Thread.Sleep(200)
serialport.WriteLine("test message" & vbCrLf & Chr(26))
System.Threading.Thread.Sleep(200)
End Sub
The thing is, it seems that this code is not working.问题是,这段代码似乎不起作用。
Can you check if this is correct or not.你能检查一下这是否正确。 Or just give me some threads which can help me with this.或者只是给我一些可以帮助我解决这个问题的线程。
This code works for me and can send a message to your phone:此代码适用于我,可以向您的手机发送消息:
{
SerialPort1.WriteLine("AT")
System.Threading.Thread.Sleep(300)
SerialPort1.WriteLine("AT+CMGF=1" & vbCrLf)
System.Threading.Thread.Sleep(300)
SerialPort1.WriteLine("AT+CSCA=" & Chr(34) & MessageCenter & Chr(34) & vbCrLf)
System.Threading.Thread.Sleep(300)
SerialPort1.WriteLine("AT+CMGS=" & Chr(34) & PhoneNumber & Chr(34) & vbCrLf)
System.Threading.Thread.Sleep(300)
SerialPort1.WriteLine(Message & Chr(26))
MsgBox("Send")
}
Note;笔记; this code I tried and received message from my phone like this;这段代码我尝试过并从我的手机收到这样的消息; "?????#$??#????". “?????#$??#????”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.