|
[EXCEL] 編寫excel vba下單訊號出現後傳簡訊
[EXCEL] 編寫excel vba下單訊號出現後傳簡訊
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button1.Click
Dim objSMS As Object
Dim ServerIp As String
Dim ServerPort As String
Dim UserID As String
Dim Passwd As String
Dim ret_code As Integer
Dim ret_description As String
Dim Tel As String
Dim Message As String
ServerIp = "api.hiair.hinet.net"
ServerPort = "8000"
UserID = "帳號"
Passwd = "密碼"
objSMS = CreateObject("HiAir.HiNetSMS")
ret_code = objSMS.StartCon(ServerIp, ServerPort, UserID, Passwd)
If ret_code = 0 Then
Tel = "0910128xxx"
Message = "簡訊測試"
ret_code = objSMS.SendMsg(Tel, Message)
ret_description = objSMS.Get_Message()
MsgBox (ret_description)
Else
ret_description = objSMS.Get_Message()
MsgBox (ret_description)
End If
objSMS.EndCon()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles Button2.Click
Dim objSMS As Object
Dim ServerIp As String
Dim ServerPort As String
Dim UserID As String
Dim Passwd As String
Dim ret_code As Integer
Dim ret_description As String
Dim Send_MSISDN As String
ServerIp = "api.hiair.hinet.net"
ServerPort = "8000"
UserID = "帳號"
Passwd = "密碼"
objSMS = CreateObject("HiAir.HiNetSMS")
ret_code = objSMS.StartCon(ServerIp, ServerPort, UserID, Passwd)
If ret_code = 0 Then
ret_code = objSMS.RecvMsg()
ret_description = objSMS.Get_Message()
Send_MSISDN = objSMS.Get_Send_MSISDN()
MsgBox (ret_description)
MsgBox (Send_MSISDN)
Else
ret_description = objSMS.Get_Message()
MsgBox (ret_description)
End If
objSMS.EndCon()
End Sub
End Class
Hinet的簡訊服務是要申請的
才能用程式去發送
你用VBA的話,還要再裝一下hinet提供的SMS COM元件
不然 objSMS = CreateObject("HiAir.HiNetSMS") 這一行應該就會錯了
使用Hinet的企業簡訊服務不過原理都一樣,只是透過HTTP來傳送而已 (國內的業者幾乎都是這樣做)
HiNet有提供SMS COM元件,表示他幫你把底層做好了,較方便使用
國內提供發簡訊的服務有很多家,有專門在做這方面服務的公司
費率比較便宜,如果你的交易訊號比較頻繁的話,建議找便宜的 |
|