Home » 文章 » 电脑技术 » Excel » 如何给员工发短信工资信息

如何给员工发短信工资信息

如何给员工发短信工资信息如何给员工发短信工资信息。本方法借助使用中国网建SMS短信通平台接口(http://www.smschinese.cn/),给员工发送短信。

Excel的VBA代码如下:

Public Function getHtmlStr(strUrl As String) ‘获取远程接口函数
On Error Resume Next
Dim XmlHttp As Object, stime, ntime
Set XmlHttp = CreateObject(“Microsoft.XMLHTTP”)
XmlHttp.Open “GET”, strUrl, True
XmlHttp.send
stime = Now ‘获取当前时间
While XmlHttp.ReadyState <> 4
DoEvents
ntime = Now ‘获取循环时间
If DateDiff(“s”, stime, ntime) > 3 Then getHtmlStr = “”: Exit Function
Wend
getHtmlStr = StrConv(XmlHttp.responseBody, vbUnicode)
Set XmlHttp = Nothing
End Function
Sub SendMsg()
If MsgBox(“确认发送短信吗?”, vbYesNo, “请选择”) = vbYes Then
Dim UseId As String, Key As String, Mob As String, Text As String, a As String, split As String
UseId = “ABC” ‘平台账号的UseId
Key = “abcdefghi123456789” ‘平台交换的Key值
For r = 4 To Sheet1.Range(“A10000”).End(xlUp).Row
‘设置接收手机号码
Mob = Sheet1.Range(“ac” & r)’AC列放接收短信的手机号码
‘设置接收内容
For c = 1 To 28
split = split & Sheet1.Cells(3, c) & Sheet1.Cells(r, c) & “,”      ‘第三行开始为发送内容
Next
split = Left(split, Len(split) – 1)
Text = split
split = “”
‘ Debug.Print Text
a = getHtmlStr(“http://sms.webchinese.cn/web_api/?Uid=” & UseId & “&Key= ” & Key & “&smsMob=” & Mob & “&smsText=” & Text & “”) ‘获取接口返回值
Select Case a
Case -1
a = “发送失败,没有该用户账户”
Case -2
a = “发送失败,接口密钥不正确”
Case -21
a = “发送失败,MD5接口密钥加密不正确”
Case -3
a = “发送失败,短信数量不足”
Case -11
a = “发送失败,该用户被禁用”
Case -14
a = “发送

微信 OR 支付宝 扫描二维码
为博主 打个赏
pay_weixinpay_zhifubao
金额随意 快来“打”我呀~