Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Web forms information (user entered) not being e-mailed

Options
  • 29-10-2007 8:48pm
    #1
    Registered Users Posts: 265 ✭✭


    I have an enquiries page on my web site. I have put the action as formail.asp. When I fill in the form with name, address, contact details etc. and submit it, an e mail comes though fine but the information in the form does not come through but instead the words "Insert your plain body text here" appear in the body of the e-mail....and nothing else.

    This would appear to be specific to hosting365 as the same routine works fine with another host.

    Can anyone shed any light this for me please? I'm hoping it's simple.


Comments

  • Registered Users Posts: 3,401 ✭✭✭randombar


    Any code we could have a look at?


  • Registered Users Posts: 265 ✭✭jellybean520


    Hi Gary,

    Code from my formmail.asp listed below and this syntax works perfectly with another host passing all the user entered data no problem.

    As I mentioned, with hosting365 I get the e-mail sent but only with "Insert here your plain body text" in the body....and nothing else.

    Contents of formmail.asp;

    <%
    Dim sMsg
    Dim sTo
    Dim sFrom
    Dim sSubject
    Dim sTextBody

    sTo = "cornelia.oconnell@gmail.com"
    sFrom = "fromaddress@maildomain.com"
    sSubject = "Insert here your subject text"
    sTextBody = "Insert here your plain body text"

    Dim objMail
    'Create the mail object
    Set objMail = Server.CreateObject("CDO.Message")

    'Set key properties
    objMail.From = sFrom
    objMail.To = sTo
    objMail.Subject= sSubject
    objMail.TextBody = sTextBody

    'Send the email
    objMail.Send

    'Clean-up mail object
    Set objMail = Nothing
    %>


    Any help with this much appreciated......


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    The reason that "Insert here your plain body text" is being sent, is because of the following line:
    sTextBody = "Insert here your plain body text"
    

    What's the ID of the form element that has the text you want to send?

    e.g. if it's

    [html]
    <textarea id="txaComments" cols="30" rows="5"></textarea>
    [/html]

    Then the line of code should be:
    sTextBody = Request.Form("txaComments")
    


  • Registered Users Posts: 265 ✭✭jellybean520


    Thanks for the tip Eoin, I'll give this a go this evening. I'm a bit new to all this so apologies in advance for the newbieness!


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Thanks for the tip Eoin, I'll give this a go this evening. I'm a bit new to all this so apologies in advance for the newbieness!

    No problems at all. Drop me a PM if you want me to look at the page this evening.


  • Advertisement
  • Registered Users Posts: 4,468 ✭✭✭matt-dublin


    This should work.
    secure(ish) as well
    <&#37;@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <%
    Dim sMsg 
    Dim sTo 
    Dim sFrom 
    Dim sSubject 
    Dim sTextBody 
    
    sTo = "cornelia.oconnell@gmail.com"
    sFrom = server.HTMLEncode(request.form("Fromaddy"))
    sSubject = server.HTMLEncode(request.form("Subjectline"))
    sTextBody = server.HTMLEncode(request.form("BodyText"))
    
    Dim objMail
    'Create the mail object 
    Set objMail = Server.CreateObject("CDO.Message")
    
    'Set key properties 
    objMail.From = sFrom 
    objMail.To = sTo 
    objMail.Subject= sSubject 
    objMail.TextBody = sTextBody 
    
    'Send the email 
    objMail.Send 
    
    'Clean-up mail object
    Set objMail = Nothing
    %>
    
    
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form method="post" id="formmail" action="">
    <table width="200" border="1">
      <tr>
        <td>Email Address: </td>
        <td><input type="text" name="Fromaddy" /></td>
      </tr>
      <tr>
        <td>Subject: </td>
        <td><input type="text" name="Subjectline" /></td>
      </tr>
      <tr>
        <td>Message: </td>
        <td><textarea name="BodyText"></textarea></td>
      </tr>
    </table>
    
    
    </form>
    
    </body>
    </html>
    


  • Registered Users Posts: 265 ✭✭jellybean520


    Hi Folks. I used Matt's code below and I got the following error message


    CDO.Message.1 error '8004020d'

    At least one of the From or Sender fields is required, and neither was found.

    /formmail.asp, line 35

    - for the record - Line 35 is "objMail.Send"

    Any help with this much appreciated.
    Cheers


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Hi Folks. I used Matt's code below and I got the following error message


    CDO.Message.1 error '8004020d'

    At least one of the From or Sender fields is required, and neither was found.

    /formmail.asp, line 35

    - for the record - Line 35 is "objMail.Send"

    Any help with this much appreciated.
    Cheers

    Can you post the updated file in it's entirety?


  • Registered Users Posts: 265 ✭✭jellybean520


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body><%@LANGUAGE=&quot;VBSCRIPT" CODEPAGE="1252"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml"&gt;

    <%
    Dim sMsg
    Dim sTo
    Dim sFrom
    Dim sSubject
    Dim sTextBody

    sTo = "cornelia.oconnell@gmail.com"
    sFrom = server.HTMLEncode(request.form("Fromaddy"))
    sSubject = server.HTMLEncode(request.form("Subjectline"))
    sTextBody = server.HTMLEncode(request.form("BodyText"))

    Dim objMail
    'Create the mail object
    Set objMail = Server.CreateObject("CDO.Message")

    'Set key properties
    objMail.From = sFrom
    objMail.To = sTo
    objMail.Subject= sSubject
    objMail.TextBody = sTextBody

    'Send the email
    objMail.Send

    'Clean-up mail object
    Set objMail = Nothing
    %>



    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form method="post" id="formmail" action="">
    <table width="200" border="1">
    <tr>
    <td>Email Address: </td>
    <td><input type="text" name="Fromaddy" /></td>
    </tr>
    <tr>
    <td>Subject: </td>
    <td><input type="text" name="Subjectline" /></td>
    </tr>
    <tr>
    <td>Message: </td>
    <td><textarea name="BodyText"></textarea></td>
    </tr>
    </table>


    </form>

    </body>
    </html>
    </body>
    </html>


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    OK, it looks like the ASP is being triggered before the form has been submitted. If you're putting the ASP in the same page that calls it, then you need to tell it when to execute.

    The code below should work for you.
    <&#37;@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <%
    If Request.ServerVariables("HTTP_METHOD") = "POST" Then
    	Dim sMsg
    	Dim sTo
    	Dim sFrom
    	Dim sSubject
    	Dim sTextBody
    
    	sTo = "cornelia.oconnell@gmail.com"
    	sFrom = server.HTMLEncode(request.form("Fromaddy"))
    	sSubject = server.HTMLEncode(request.form("Subjectline"))
    	sTextBody = server.HTMLEncode(request.form("BodyText"))
    
    	Dim objMail
    	'Create the mail object
    	Set objMail = Server.CreateObject("CDO.Message")
    
    	'Set key properties
    	objMail.From = sFrom
    	objMail.To = sTo
    	objMail.Subject= sSubject
    	objMail.TextBody = sTextBody
    
    	'Send the email
    	objMail.Send
    
    	'Clean-up mail object
    	Set objMail = Nothing
    	Response.Write "email sent"
    End If
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<title>Untitled Document</title>
    	</head>
    	<body>
    		<form method="post" id="formmail" action="">
    			<table width="200" border="1">
    				<tr>
    					<td>Email Address: </td>
    					<td><input type="text" name="Fromaddy" /></td>
    				</tr>
    				<tr>
    					<td>Subject: </td>
    					<td><input type="text" name="Subjectline" /></td>
    				</tr>
    				<tr>
    					<td>Message: </td>
    					<td><textarea name="BodyText"></textarea></td>
    				</tr>
    				<tr>
    					<td>&nbsp;</td>
    					<td><input type="submit" name="cmdSubmit" id="cmdSubmit" value="send"></td>
    				</tr>
    			</table>
    		</form>
    	</body>
    </html>
    


  • Advertisement
  • Registered Users Posts: 265 ✭✭jellybean520


    Thanks a million, that worked . much appreciated. :)

    cheers


  • Registered Users Posts: 4,468 ✭✭✭matt-dublin


    whoops, forgot about that! well spotted eoin!


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    whoops, forgot about that! well spotted eoin!

    Didn't really spot it - ran into the same problem when I tested it at home!


  • Registered Users Posts: 4,468 ✭✭✭matt-dublin


    eoin_s wrote: »
    Didn't really spot it - ran into the same problem when I tested it at home!
    lol


Advertisement