我想向很多人发送短信。 我在 MySQL 表中有每个人的人类型和电话号码。 使用存储过程,我调用数据库中的存储过程以获取特定类型的所有人的电话号码列表,并将其存储在DataTable
对象中。 我有一个 URL,我需要使用它来为同一类型的所有人发送所有消息。 以下代码中的变量s
是来自下拉控件的人员类型:
Dim ta As New dataset1TableAdapters.pro_selectsmsTableAdapter
Dim dt As dataset1.pro_selectsmsDataTable = ta.GetData(s)
如何遍历生成的DataTable
并使用 URL 将 SMS 消息发送给每个? 变量 dt
具有与存储在 s
中的类型匹配的人员的电话号码列表。 请帮我解决这个问题。 我是 VB.NET 新手。
这是你要找的那种东西吗?
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