1

How to pass multiple variables to a link/href without having to open the browser using VBScript? The goal is to save/insert/update depending on the parameters that was passed on the URL, and the IIS Webserver would have to do the database change instead of the VBScript. The VBScript runs on schedule and would not want to open browser on the server each time it is executed.

My VBS code below:

Function HTMLEncode(Text)
    Dim i 
    Dim acode 
    Dim repl 
    HTMLEncode = Text 
    For i = Len(HTMLEncode) To 1 Step -1 
        acode = Asc(Mid(HTMLEncode, i, 1))
        Select Case acode 
            Case 32 
                repl = " " 
            Case 34 
                repl = """ 
            Case 38 
                repl = "&" 
            Case 60 
                repl = "<" 
            Case 62 
                repl = ">" 
            Case acode => 32 AND acode <= 127 
                ' don't touch alphanumeric chars 
            Case Else 
                repl = "&#" & CStr(acode) & ";" 
        End Select 
        If Len(repl) Then 
            HTMLEncode = Left(HTMLEncode, i - 1) & repl & Mid(HTMLEncode,+ 1) 
            repl = "" 
        End If 
    Next 
End Function 


strBody = "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">" & _
  "<html>" & _
    "<head>" & _
    "<title>TEST</title>" & _
    "</head>" & _
    "<body bgcolor=""#FFFFFF"">" & _
    "<p> The user bla bla bla </p>" & _
    "<p><b> &nbsp;&nbsp;" & _
    "<br><br><br><br> This message is sent from an un-monitored mailbox, please do not reply.  " & _
    "</p>" & _
    "</body>" & _
    "</html>"

    strBody = HTMLEncode(strBody)

    myURL = "http://www.test.com/sendmail.asp?body=" & strBody

Set req = CreateObject("MSXML2.XMLHTTP.6.0")
req.Open "GET", myURL, False
req.Send
Sid
  • 765
  • 5
  • 29
  • 57
  • Try in command window `cscript.exe ` with `Set req = CreateObject("MSXML2.ServerXMLHTTP")` as described [here](http://stackoverflow.com/a/26565113/3394380) – yW0K5o Mar 10 '15 at 18:47
  • Hi, tried it and this works in a simple way, but when my variables have multiline, or like the HTMLBody, it doesnt pass the variable right. – Sid Mar 10 '15 at 18:49
  • You need to HTMLEncode your content. If you post your actual code we could be more helpful. – Nathan Rice Mar 10 '15 at 18:55
  • I posted my sample code, i changed my title to focus on the HTMLEncode portion – Sid Mar 10 '15 at 19:37

0 Answers0