感谢大佬分享方法,下面是我做的一个微信公众号模板消息,文本消息群发的小案例
Dim cm d As new SQL Command
cm d.Connection Name = "我是数据"
cm d.Command Text = "Se lect * FR OM 表名(nolock)"
Dim afi As DataTable = cm d.ExecuteReader()
Dim drsi As List(Of DataRow) = afi.Se lect("","注册日期")
For Each r As DataRow In drsi
Dim jo As New JObject
jo("touser") = r("openid").ToString()
jo("msgtype") = "text"
jo("text") = New JObject
jo("text")("content") = "您好,我是TOP YOU 余 一个论坛不老不新的用户!"
Dim URL As String = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}"
Dim hc As New HttpClient(CExp(URL, Functions.Execute("GetAccessToken")))
hc.Content = jo.ToString()
jo = JObject.Parse(hc.GetData())
If jo("errcode") = "0" Then
MessageBox.Show("消息发送成功")
Else
MessageBox.show("消息发送失败,原因:" & vbcrlf & jo("errmsg").ToString)
End If
Next
[此贴子已经被作者于2019/9/20 11:39:43编辑过]