How to send sms from vb.net
I need to setup an application with the purpose of sending an sms . Already know the sms gateway type . But i really want to integrate with sim . i need to 开发者_开发技巧send via a sim ( which was connected to pc through COM port)
Here you can find free library that can help you with your task: http://www.codeproject.com/KB/cs/SMS.aspx?msg=3179142
Or you can opt some commercial library that do the same thing: http://www.logixmobile.com/products/mcorelib/index.asp, for instance.
Imports System.IO.Ports
Public Class Exampl1
Public Class Form1
Dim WithEvents serialport As New IO.Ports.SerialPort
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To My.Computer.Ports.SerialPortNames.Count - 1
.Items.Add(My.Computer.Ports.SerialPortNames(i))
Next
End Sub
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
End Class
End Class
精彩评论