简体   繁体   English

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

[英]Sending SMS messages via a URL using VB.NET

I want to send an SMS message to many people. 我想向许多人发送短信。 I have the person type and phone number for each person in a MySQL table. 我在MySQL表中有每个人的人类型和电话号码。 Using a stored procedure, I am calling a stored procedure in the database to get a list of phone numbers for all the people of a particular type and store it in a DataTable object. 使用存储过程,我正在数据库中调用存储过程以获取特定类型的所有人员的电话号码列表,并将其存储在DataTable对象中。 I have one URL that I need to use to send all the messages for all the people of that same type. 我有一个URL,我需要使用它为所有相同类型的人发送所有消息。 The variable s in the below code is the person type which comes from a drop-down control: 以下代码中的变量s是来自下拉控件的人员类型:

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

How do I loop through the resulting DataTable and send the SMS message to each one using the URL? 如何遍历生成的DataTable并使用URL向每个用户发送SMS消息? The variable dt has the list of phone numbers for the people who match the type stored in s . 变量dt包含与s存储的类型匹配的人员的电话号码列表。 Please help me solve this problem. 请帮我解决这个问题。 I am new to VB.NET. 我是VB.NET的新手。

Is this the kind of thing you are looking for? 这是您要找的东西吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM