使用VB.NET通过URL发送SMS消息

时间:2012-06-27 07:12:03

标签: vb.net url

我想向很多人发送短信。我有一个MySQL表中每个人的人员类型和电话号码。使用存储过程,我在数据库中调用存储过程以获取特定类型的所有人的电话号码列表,并将其存储在DataTable对象中。我有一个URL,我需要用它来发送所有相同类型的人的所有消息。以下代码中的变量s是来自下拉控件的人员类型:

Dim ta As New dataset1TableAdapters.pro_selectsmsTableAdapter
Dim dt As dataset1.pro_selectsmsDataTable = ta.GetData(s)    

如何循环生成DataTable并使用网址向每个人发送短信?变量dt包含与s中存储的类型匹配的人员的电话号码列表。请帮我解决这个问题。我是VB.NET的新手。

1 个答案:

答案 0 :(得分:0)

这是你要找的东西吗?

Private Sub sendSmsMessage(ByVal message As String, ByVal s As String)
    Dim ta As New dataset1TableAdapters.pro_selectsmsTableAdapter
    Dim dt As dataset1TableAdapters.pro_selectsmsDataTable = ta.GetData(s)
    For Each dr As DataSet1.pro_selectsmsRow In dt
        Dim client As System.Net.WebRequest = System.Net.HttpWebRequest.Create(getSmsUrl("", "")) 'dr.fld_phone, message))
        Dim response As System.Net.WebResponse = client.GetResponse()
        Dim reader As StreamReader = New StreamReader(response.GetResponseStream())
        Dim responseText As String = reader.ReadToEnd()
        ' look at response text from website to see if operation succeeded
    Next
End Sub

Private Function getSmsUrl(ByVal phone As String, ByVal message As String) As String
    ' build proprietary url and return it here
End Function