一段使用纯ASP程序用串口GSM猫进行短信发送的代码,测试完全成功,分享一下。
如果哪位大侠有时间把它做成组件,也别忘了分享一下哦。
<%
Function uni(Chinese)
For i = 1 to Len (Chinese)
a=Mid(Chinese, i, 1)
uni=uni & right("0000"& Hex(Ascw(a)) ,4)
next
End Function
mobile=request("mb")
content=request("ct")
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.CreateTextFile("COM2")
PDStr="AT"+Chr(13)+"AT+CSMP=17,167,0,8"+Chr(13)+"AT+CMGF=1"+Chr(13)+"AT+CMGS="+Chr(34)+mobile+Chr(34)+Chr(13)+uni(content)+Chr(13)+Chr(26)+Chr(13)+"AT+CMGF=0"+Chr(13)+"AT+CMGS=17"+Chr(13)+Chr(13)+Chr(13)
response.write PDStr
MyTextFile.WriteLine(PDStr)
MytextFile.Close
%>
Function uni(Chinese)
For i = 1 to Len (Chinese)
a=Mid(Chinese, i, 1)
uni=uni & right("0000"& Hex(Ascw(a)) ,4)
next
End Function
mobile=request("mb")
content=request("ct")
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.CreateTextFile("COM2")
PDStr="AT"+Chr(13)+"AT+CSMP=17,167,0,8"+Chr(13)+"AT+CMGF=1"+Chr(13)+"AT+CMGS="+Chr(34)+mobile+Chr(34)+Chr(13)+uni(content)+Chr(13)+Chr(26)+Chr(13)+"AT+CMGF=0"+Chr(13)+"AT+CMGS=17"+Chr(13)+Chr(13)+Chr(13)
response.write PDStr
MyTextFile.WriteLine(PDStr)
MytextFile.Close
%>
将其存为 sms.asp
发表评论