Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Capture ASP to HTML code from Server

    Is there anyway to take the generated ASP code and save it? I have a dynamically created order form which also needs to be sent in an email(html).

    I found this, but can't get it to work at all.

    http://www.aspemporium.com/aspEmpori...id=1563&fid=24


    Thanks, Carini

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Welcome here. I'm not sure i understand what you try to do. If you want to reuse asp-code, then the easiest thing to do is save it in a seperate file and (with file-extensions .asp) and then use a server side include (SSI) to include it in the files you want to use it in.

    Like
    <!--#include file='reusecode.asp'-->

    Where reusecode.asp contains the asp-code you want to reuse. Like
    <%
    response.write("test")
    %>

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,047
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Use Microsoft's XMLHTTP Object

  • #4
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Raf - Sorry I wasn't too clear. I was wondering if you can capture the generated ASP page(HTML) that the server sends to the client. Just like if you were the client, and did a "Save As" of the webpage. I have a dynamic form, which I also need to send as a html email. So I just wanted to take the table the form produces, and send it via email.

    Glenn, thanks for the link, I'll try that, but I just hope it's already installed on the server because I have no control over it.

    Carini

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What you sent to the client is straight html.

    The easies and most efficient way is instead of response.writing it or going out of asp mode like
    <%
    some aspcode
    %>
    some html
    <%some asp %>

    , you just stay is ASP-mode and add all the html you also want to mail to a stringvariable. And at the end of the page you have one variable whith all the html code in. Then you can do one response.write + use the variable as the emails body.

    So you'de have stuff like

    Code:
    dim output
    output="<table ...><tr>..."
    output= output & "<td>...</td>..."
    output= output & "The rest..."
    ...
    response.write("output")
    ... your mailcode
    Instead of
    Code:
    response.write("<table ...><tr>...")
    response.write("<td>...</td>...")
    ...
    Last edited by raf; 10-21-2003 at 07:59 AM.

  • #6
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hehe thanks raf!!! that worked perfectly, i guess I was trying to be lazy and not type everything out. I'm fairly new to asp, and didn't now if there was some kind of server command to call for the generated html

    Carini

  • #7
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't know of a servercommand to do that.

    Maybe you can work something out by caching the output on a proxyserver and then reading that or so, but i don't have aclue how to do that.
    You can also buffer the outpu while the script is executed, but i never saw a method to store the buffer-content in a variale + then you have all output (also the html header etc)

    Just storing all or part of the output in a variable is easy, flexible, clean and efficient ...

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,047
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Originally posted by Carini
    Glenn, thanks for the link, I'll try that, but I just hope it's already installed on the server because I have no control over it.
    As mentioned by 4guysfromrolla, you need MSXML installed in the server. If the server has at least IE5 browser, it has MSXML installed. But you can download it in the link they provided.
    Here's the sample code they showed. I modified it a bit for your needs:
    Code:
    <%
      Response.Buffer = True
      Dim objXMLHTTP, xml, emailBody
    
      ' Create an xmlhttp object:
      Set xml = Server.CreateObject("Microsoft.XMLHTTP")
      ' Or, for version 3.0 of XMLHTTP, use:
      ' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
    
      ' Opens the connection to the remote server.
      xml.Open "GET", "http://mydomain.com/somepage.asp", False
    	
      ' Actually Sends the request and returns the data:
      xml.Send
    
      emailBody =  xml.responseText
      
      Set xml = Nothing
      
      'send emailBody in email here
    
    %>

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's some pretty cool **** Glenn.

    P.S. In this post, "****" means "code".
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #10
    Regular Coder
    Join Date
    Mar 2003
    Posts
    241
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have basically the same script but with some error-checking:


    Code:
    <%@LANGUAGE="VBScript", EnableSessionState = False %>
    <%
    Option Explicit
    Response.Buffer = False
    
    
    Function GrabPage(strURL)
    	Dim objXML
    	Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
    	objXML.Open "GET", strURL, False
    	objXML.Send
    	
    	If Err.Number = 0 Then
    		If objXML.Status = 200 then
    			GrabPage = objXML.ResponseText
    		Else
    			GrabPage = "Incorrect URL"
    		End if
    	Else
    		GrabPage = Err.Description
    	End If
    	
    	Set objXML = Nothing
    End Function
    %>
    Then to write the contents on a page, you simply include this:

    <% response.write(GrabPage("http://www.bleh.zz/")) %>
    or
    <% myVariable = GrabPage("http://www.bleh.zz/") %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •