以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=62994)

--  作者:yjd
--  发布时间:2015/1/11 21:34:00
--  [求助]
老师,短信群发代码怎么写,发一个短信点一下鼠标太麻烦,谢谢!
For Each r As Row In Tables("对公客户明细").rows
    Dim server As String = e.Form.Controls("TextBox1").Text
    Dim phones As String = r("手机")
    Dim context As String = System.Web.HttpUtility.UrlEncode(e.Form.Controls("TextBox3").Text)
    If phones > "" AndAlso context > "" Then \'如果输入了电话号码和内容
        e.Form.Controls("btnSend").Enabled = False \'禁用发送按钮,避免用户重复单击发送按钮
    End If
    Dim url  As String = server & "/?numbers=" & phones & "&text=" & context
    try
        Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
        Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
        rsps.close
        \'Dim stm As System.IO.Stream = rsps.GetResponseStream()
        \'Dim reader As New System.IO.StreamReader(stm)
        \'Dim strResult As String = reader.ReadToEnd
        \'msgbox(strResult)
        msgbox("提交发送成功")
    catch ex As exception
        msgbox("发送失败,请确认服务器地址设置正确!")
    End try
Next

--  作者:有点甜
--  发布时间:2015/1/11 21:49:00
--  

方法一

 


Dim server As String = e.Form.Controls("TextBox1").Text
Dim phones As String = ""
For Each r As Row In Tables("对公客户明细").rows
    phones &= r("手机") & ","
Next
Dim context As String = System.Web.HttpUtility.UrlEncode(e.Form.Controls("TextBox3").Text)
If phones > "" AndAlso context > "" Then \'如果输入了电话号码和内容
    e.Form.Controls("btnSend").Enabled = False \'禁用发送按钮,避免用户重复单击发送按钮
End If
Dim url  As String = server & "/?numbers=" & phones.Trim(",") & "&text=" & context
try
    Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
    Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
    rsps.close
    \'Dim stm As System.IO.Stream = rsps.GetResponseStream()
    \'Dim reader As New System.IO.StreamReader(stm)
    \'Dim strResult As String = reader.ReadToEnd
    \'msgbox(strResult)
    msgbox("提交发送成功")
catch ex As exception
    msgbox("发送失败,请确认服务器地址设置正确!")
End try


--  作者:有点甜
--  发布时间:2015/1/11 21:52:00
--  

 方法二

 

Dim MsPhone As String = ""
For Each r As Row In Tables("对公客户明细").rows
    Dim server As String = e.Form.Controls("TextBox1").Text
    Dim phones As String = r("手机")
    Dim context As String\' = System.Web.HttpUtility.UrlEncode(e.Form.Controls("TextBox3").Text)
   
    Dim url  As String = server & "/?numbers=" & phones & "&text=" & context
    try
        Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
        Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
        rsps.close
        \'Dim stm As System.IO.Stream = rsps.GetResponseStream()
        \'Dim reader As New System.IO.StreamReader(stm)
        \'Dim strResult As String = reader.ReadToEnd
        \'msgbox(strResult)
    catch ex As exception
        MsPhone = MsPhone & r("手机号") & ","
    End try
Next
If msPhone > "" Then
    MessageBox.Show(MsPhone & "发送失败,请确认服务器地址设置正确!","提示")
End If


--  作者:yjd
--  发布时间:2015/1/11 22:03:00
--  

Dim server As String = e.Form.Controls("TextBox1").Text
Dim phones As String = ""
For Each r As Row In Tables("对公客户明细").rows
    phones &= r("手机") & ","
Next
Dim context As String = System.Web.HttpUtility.UrlEncode(e.Form.Controls("TextBox3").Text)
If phones > "" AndAlso context > "" Then \'如果输入了电话号码和内容
    e.Form.Controls("btnSend").Enabled = False \'禁用发送按钮,避免用户重复单击发送按钮
End If
Dim url  As String = server & "/?numbers=" & phones.Trim(",") & "&text=" & context
try
    Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
    Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
    rsps.close
    \'Dim stm As System.IO.Stream = rsps.GetResponseStream()
    \'Dim reader As New System.IO.StreamReader(stm)
    \'Dim strResult As String = reader.ReadToEnd
    \'msgbox(strResult)
    msgbox("提交发送成功")
catch ex As exception
    msgbox("发送失败,请确认服务器地址设置正确!")
End try

老师,只发了一条。我搞不清了!

--  作者:有点甜
--  发布时间:2015/1/11 22:05:00
--  

 哦,写错了

 

For Each r As Row In Tables("对公客户明细").rows
    phones &= r("手机") & "|"
Next

 

 

Dim url  As String = server & "/?numbers=" & phones.Trim("|") & "&text=" & context


--  作者:yjd
--  发布时间:2015/1/11 22:25:00
--  
Dim server As String = e.Form.Controls("TextBox1").Text
Dim phones As String = ""
For Each r As Row In Tables("对公客户明细").rows
    phones &= r("手机") & "|"
Next
Dim context As String = System.Web.HttpUtility.UrlEncode(e.Form.Controls("TextBox3").Text)
If phones > "" AndAlso context > "" Then \'如果输入了电话号码和内容
    e.Form.Controls("btnSend").Enabled = False \'禁用发送按钮,避免用户重复单击发送按钮
End If
Dim url  As String = server & "/?numbers=" & phones.Trim("|") & "&text=" & context
try
    Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
    Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
    rsps.close
    \'Dim stm As System.IO.Stream = rsps.GetResponseStream()
    \'Dim reader As New System.IO.StreamReader(stm)
    \'Dim strResult As String = reader.ReadToEnd
    \'msgbox(strResult)
    msgbox("提交发送成功")
catch ex As exception
    msgbox("发送失败,请确认服务器地址设置正确!")
End try


老师,只发了一条。

--  作者:有点甜
--  发布时间:2015/1/11 22:27:00
--  

 不可能。

 

 那你就用方法二。


--  作者:yjd
--  发布时间:2015/1/11 23:15:00
--  
Dim server As String = e.Form.Controls("TextBox1").Text
Dim phones As String = ""
For Each r As Row In Tables("对公客户明细").rows
    phones &= r("手机") & "|"
Next
Dim context As String = System.Web.HttpUtility.UrlEncode(e.Form.Controls("TextBox3").Text)
If phones > "" AndAlso context > "" Then \'如果输入了电话号码和内容
    e.Form.Controls("btnSend").Enabled = False \'禁用发送按钮,避免用户重复单击发送按钮
End If
Dim url  As String = server & "/?numbers=" & phones.Trim("|") & "&text=" & context
try
    Dim rqst As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(url)
    Dim rsps As System.Net.HttpWebResponse = rqst.GetResponse
    rsps.close
    \'Dim stm As System.IO.Stream = rsps.GetResponseStream()
    \'Dim reader As New System.IO.StreamReader(stm)
    \'Dim strResult As String = reader.ReadToEnd
    \'msgbox(strResult)
    msgbox("提交发送成功")
catch ex As exception
    msgbox("发送失败,请确认服务器地址设置正确!")
End try


您看有问题吗?只发送了一条。

--  作者:有点甜
--  发布时间:2015/1/11 23:43:00
--  

 代码没问题,除非你数据有问题。

 

 只要合成得phones是这种格式即可 13827126079|13888888888|13812345678

 

 不行就看7楼


--  作者:yjd
--  发布时间:2015/1/12 21:56:00
--  
甜版主,您的两个方法我都试了,还是不可以。第一种方法成功一笔,第二种方法系统不响应。我的手机号是绑定表的“手机”列,麻烦您帮帮忙,谢谢!
[此贴子已经被作者于2015-1-12 21:58:10编辑过]