Results 1 to 4 of 4

Thread: Form-submitted e-mail is blank

  1. #1

    Form-submitted e-mail is blank

    This is my first shot at VBscripting, so I'm having a few minor issues.

    I have a form that I want submitted via e-mail. The 'send the e-mail' part of the code on the .asp page works fine, but the 'gather all the form data' part doesn't and I'm not entirely sure where the code is getting 'confused'.

    Here's the code (I've left off the mailer parts, since I know those work):


    it's kind of lengthy -

    Code:
    strMsgInfo = strMsgInfo & 
    
    MunLJ=request.querystring("MunLJ")
    email=request.querystring("email")
    charLJ=request.querystring("charLJ")
    charname=request.querystring("charname")
    
    response.write MunLJ & "<br />"
    response.write email & "<br />"
    response.write charLJ & "<br />"
    response.write charname & "<br />"
    
    
    <!--- Which IM client do you use --->
    
    if request.form("IM1")="on" then
       response.write "AIM <br />"
    end if
    AIMid=request.querystring("AIMid")
    response.write AIMid & "<br />"
    
    if request.form("IM2")="on" then
       response.write "Y!H <br />"
    end if
    Yahid=request.querystring("Yahid")
    response.write Yahid & "<br />"
    
    if request.form("IM3")="on" then
       response.write "MSN <br />"
    end if
    MSNid=request.querystring("MSNid")
    response.write MSNid & "<br />"
    
    if request.form("IM4")="on" then
       response.write "ICQ <br />"
    end if
    ICQid=request.querystring("ICQid")
    response.write ICQid & "<br />"
    
    <!--- Character info Mark II --->
    
    charcanon=request.querystring("charcanon")
    canonlink=request.querystring("canonlink")
    
    response.write charcanon & "<br />"
    response.write canonlink & "<br />"
    
    
    <!--- Character info Mark III - canon description I --->
    
    comm=request.form("candesc1")
    comm=replace(comm,vbcrlf,"<br />")
    
    
    <!--- Character info Mark IV - canon description II --->
    
    comm1=request.form("candesc2")
    comm1=replace(comm,vbcrlf,"<br />")
    
    
    <!--- Character info Mark V - character description I --->
    
    comm2=request.form("chardesc")
    comm2=replace(comm,vbcrlf,"<br />")
    
    
    
    <!--- Which Dresden books have you read --->
    
    if request.form("Dresden1")="on" then
       response.write "Storm Front <br />"
    end if
    if request.form("Dresden2")="on" then
       response.write "Fool Moon <br />"
    end if
    if request.form("Dresden3")="on" then
       response.write "Grave Peril <br />"
    end if
    if request.form("Dresden4")="on" then
       response.write "Summer Knight <br />"
    end if
    if request.form("Dresden5")="on" then
       response.write "Death Masks <br />"
    end if
    if request.form("Dresden6")="on" then
       response.write "Blood Rites <br />"
    end if
    if request.form("Dresden7")="on" then
       response.write "Dead Beat <br />"
    end if
    if request.form("Dresden8")="on" then
       response.write "Proven Guilty <br />"
    end if
    
    
    strMsgFooter = vbCrLf & "End of character app"
    
    Mailer.BodyText = strMsgHeader & strMsgInfo & strMsgFooter
    Thanks in advance...

  2. #2
    Bahamas Mon
    Join Date
    May 06
    Location
    Nassau, Bahamas
    Posts
    2,989

    Re: Form-submitted e-mail is blank

    Is this ASP or ASP.Net?

    For ASP download this example ..
    http://www.vbforums.com/attachment.p...chmentid=47919


    Code:
    <%@ Language="VBScript" %> 
    <%
    
    '// FORCE DECLARATION
    Option Explicit
    
    '// SET HEADERS
    Response.Buffer = True
    Response.Expires = 0
    Response.ExpiresAbsolute = Now() - 1
    Response.AddHeader "cache-control","private"
    Response.AddHeader "pragma", "no-cache"
    
    '// DECLARATIONS
    Private toname
    Private tofrom
    Private tosubject
    Private toredirect
    
    
    '// SETTINGS
    toname = Request.Form("to")
    tofrom = Request.Form("from")
    tosubject = Request.Form("subject")
    toredirect = Request.Form("redirect")
    
    
    '// IF THERE IS FORM DATA
    If Request.Form <> "" Then
    	Call Visitor_Mail()
    	Response.Redirect toredirect
    Else
    '// ELSE DISPLAY PAGE NOT FOUND
    	Response.Status 	= "404 Not Found"
    	Response.End
    End If
    
    
    '// FIELDS FROM FORM
    Private Function FormString()
    	Dim i, TheString
    	For i = 1 to (Request.Form.Count)
    		If Request.Form.Key(i) <> "to" And Request.Form.Key(i) <> "redirect" Then
    			TheString = TheString & vbCrLf & "<b>" & Request.Form.Key(i) & "</b> = " & Request.Form.Item(i) & "<br>"
    		End If
    	Next
    	FormString = TheString
    End Function
    
    '// SEND MAIL
    Private Sub Visitor_Mail()    
    	DIM objMessage 
    	DIM objConfig 
    	DIM Flds
    On Error Resume Next
    	SET objMessage = CreateObject("cdo.message")
    	SET objConfig = CreateObject("cdo.configuration")
    	SET Flds = objConfig.Fields
    	Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    	Flds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    	Flds.Update
    	SET objMessage.Configuration = objConfig
    	objMessage.FROM = tofrom
    	objMessage.To = toname
    	'// objMessage.BCC="me@me.com"
    	objMessage.Subject = tosubject
    	'// objMessage.TextBody = HTML
    	objMessage.HTMLBody = FormString
    	objMessage.Fields.Update
    	objMessage.Send
    	SET objMessage = NOTHING
    	SET objConfig = NOTHING
    	
    	If Err <> 0 Then
    		RESPONSE.WRITE "User Mail Error: " & Err.Description
    		response.end
    	End If
        
    On Error Goto 0
        
    End Sub
    
    %>
    Last edited by rory; Jun 22nd, 2006 at 07:28 PM.

  3. #3

    Re: Form-submitted e-mail is blank

    Thanks.

    I'm pretty sure it's ASP.

    I'll let you know how this goes.

  4. #4
    Bahamas Mon
    Join Date
    May 06
    Location
    Nassau, Bahamas
    Posts
    2,989

    Re: Form-submitted e-mail is blank

    ok if its ASP you want to get rid of .

    "<br />"

    Should be "<br>"

    and <!-- ... etc .. that goes in HTML .. or do Response.Write "<!-- ... etc "

    also you're looking for Form Post Data as well as Querystrings in the same code .. if its coming from a Form with Post it will just be Request(" .. or Request.Form(" ..

Posting Permissions

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