SMS with winHttp Runtime Error (1 Viewer)

mattkorguk

Registered User.
Local time
Today, 09:06
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. :confused:
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
You'll also need the url encoding bit too.
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
And here's the code behind my form;
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
 

jdraw

Super Moderator
Staff member
Local time
Today, 04:06
Joined
Jan 23, 2006
Messages
15,379
Just a guess, but is it possible there is a missing reference?
 

mattkorguk

Registered User.
Local time
Today, 09:06
Joined
Jun 26, 2007
Messages
301
Just a guess, but is it possible there is a missing reference?
Thanks for the response. I have been through all associated references using;
Code:
Sub ListReferences()
Dim refCurr As Reference
  For Each refCurr In Application.References
    Debug.Print refCurr.Name & ": " & refCurr.FullPath
  Next
End Sub
And all are present and correct. :(
 

Users who are viewing this thread

Top Bottom