mattkorguk
Registered User.
- Local time
- Today, 02:14
- Joined
- Jun 26, 2007
- Messages
- 301
Hi All,
I've put together an SMS sending form which works fine on my full version of Access 2003 but on a users Runtime version they receive an error.
The error is -2147012867 / WinHttp.WinHttpRequest
Does anyone know if this function is/ isn't available using Runtime?
Here's the full code in use, any pointers would be much appreciated;
You'll also need the url encoding bit too.
And here's the code behind my form;
I've put together an SMS sending form which works fine on my full version of Access 2003 but on a users Runtime version they receive an error.
The error is -2147012867 / WinHttp.WinHttpRequest
Does anyone know if this function is/ isn't available using Runtime?
Here's the full code in use, any pointers would be much appreciated;
Code:
Function SendMessage(sUserName, sPassword, sMobileNumber, sSenderNumberorName, sMessage)
On Error GoTo SMSerr
Dim xmlhttp As Object
Set xmlhttp = New WinHttpRequest
Dim sResponse, sUN, sPW, sTO, sFR, sMESS, ProxyUser, ProxyPword
ProxyUser = [Forms]![frmSend_SMS].[ProxyUser]
ProxyPword = "name\" & [Forms]![frmSend_SMS].[ProxyPword]
sUN = URLEncode(sUserName)
sPW = URLEncode(sPassword)
sTO = URLEncode(sMobileNumber)
sFR = URLEncode(sSenderNumberorName)
sMESS = URLEncode(sMessage)
xmlhttp.Open "GET", "[URL="http://www.textapp.net/webservice/httpservice.aspx"][COLOR=#0000ff]http://www.textapp.net/webservice/httpservice.aspx[/COLOR][/URL]?", False
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.setProxy HTTPREQUEST_PROXYSETTING_PROXY, "servername:port", "*.textapp.net"
xmlhttp.SetCredentials ProxyUser, ProxyPword, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
xmlhttp.Send ("method=sendsms&returncsvstring=false " & _
"&externallogin=" & sUN & "&password=" & sPW & _
"&clientbillingreference=clientbillingreference" & _
"&clientmessagereference=clientmessagereference" & _
"&originator=" & sFR & _
"&destinations=" & sTO & "&body=" & sMESS & "&validity=72&charactersetid=2" & _
"&replymethodid=1&replydata=&statusnotificationurl=")
sResponse = xmlhttp.responseText
Set xmlhttp = Nothing
SendMessage = sResponse
Exit Function
SMSerr:
MsgBox Err.Description & " / " & Err.Number
End Function
Code:
Function URLEncode(strData)
Dim i, strTemp, strChar, strOut, intAsc
strTemp = Trim(strData)
For i = 1 To Len(strTemp)
strChar = Mid(strTemp, i, 1)
intAsc = Asc(strChar)
If (intAsc >= 48 And intAsc <= 57) Or _
(intAsc >= 97 And intAsc <= 122) Or _
(intAsc >= 65 And intAsc <= 90) Then
strOut = strOut & strChar
Else
strOut = strOut & "%" & Hex(intAsc)
End If
Next
URLEncode = strOut
End Function
Code:
Dim sMobileNumber1 As String
DoCmd.SetWarnings False
Me.Refresh
If Len(Me.sMessage) > 160 Then
MsgBox "Length of text message cannot exceed 160 characters. Please adjust.", vbOKOnly, "Messaging Error"
Forms!frmSend_SMS!sMessage.SetFocus
Exit Sub
End If
If Left(Me.sMobileNumber, 1) = 0 Then
sMobileNumber1 = 44 & Mid(Me.sMobileNumber, 2)
End If
SendMessage Me.sUserName, Me.sPassword, sMobileNumber1, Me.sSenderNumberorName, Me.sMessage
DoCmd.OpenQuery "qrySMS-Note"
MsgBox "Your message has been sent to " & Me.sMobileNumber & ".", vbOKOnly, "Sent"
DoCmd.Close acForm, "frmSend_SMS", acSaveNo
[Forms]![frmIndividual].SMSsent = "Yes"
DoCmd.SetWarnings True