'Sending SMS through GSM modem to mobile phone

Using VB.NET I need to send a SMS using GSM modem to a mobile phone.

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.



Solution 1:[1]

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; "?????#$??#????".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bugs