Print Page | Close Window

cdonts form not formatting

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=10074
Printed Date: 31 March 2026 at 3:06pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: cdonts form not formatting
Posted By: walrus
Subject: cdonts form not formatting
Date Posted: 21 April 2004 at 1:45am

Hi. I have a simple form that is being processed by the following script. The top three field don't have a line break in the form response email but the rest are fine. Could anyone advise me how to amend the script so the response email reads the fields on different lines please.

<%@ language= "VBscript" %>
<% Option Explicit
Dim NewMail, Body
Set NewMail = Server.CreateObject("CDONTS.NewMail")
NewMail.To= " mailto:sales@connexus.com - sales@connexus.com "
NewMail.From= request.form("Email")
NewMail.Subject = "Online Contact Form"
NewMail.Body = "Interested in Purchasing a Pre-Owned Mercedes or BMW: " & request.form("Purchasing") & vbcrlf & "Interested in BACK TRADING your car (Car + Cash): " & request.form("Backtrading") & vbcrlf & "Interested in a Trade-In Evaluation: " & request.form("Evaluation") & vbcrlf & "Name: " & request.form("Name") & vbcrlf & "Company: " & request.form("Company")  & vbcrlf & "Phone: " & request.form("Phone") & vbcrlf & "Fax: " & request.form("Fax")  & vbcrlf & "Comments: " & request.form ("Comments")  
NewMail.Send
Response.Redirect("thanks1.asp")
Set NewMail=Nothing
%>

Many thanks for any light that can be shed on this.




Replies:
Posted By: dpyers
Date Posted: 21 April 2004 at 3:54am
What does it look like if you comment out the redirect and do a response.write NewMail.body just before the send?

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: walrus
Date Posted: 21 April 2004 at 4:14am

Thanks for helping Dpyers. Mmmm....just tried that and got this message on submitting form:

Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'Body'
/contact_post.asp, line 9

Am I supposed to add the line "response.write NewMail.body" just as you have written it? Sorry, no nothing about this stuff.

 



Posted By: Phat
Date Posted: 21 April 2004 at 5:28am
try

Dim strBody

strBody = "Interested in Purchasing a Pre-Owned Mercedes or BMW: " & request.form("Purchasing") & vbcrlf & "Interested in BACK TRADING your car (Car + Cash): " & request.form("Backtrading") & vbcrlf & "Interested in a Trade-In Evaluation: " & request.form("Evaluation") & vbcrlf & "Name: " & request.form("Name") & vbcrlf & "Company: " & request.form("Company")  & vbcrlf & "Phone: " & request.form("Phone") & vbcrlf & "Fax: " & request.form("Fax")  & vbcrlf & "Comments: " & request.form ("Comments") 

Response.Write(strBody)


Posted By: walrus
Date Posted: 21 April 2004 at 5:48am
Thanks for your help Phat. Now....I have no idea what to do with it. Do I change all my NewMail to strBody? Do I add this in and comment out these fields in the original script? Sorry, I know nothing about scripts. 


Posted By: dpyers
Date Posted: 21 April 2004 at 2:45pm

Just recalled that the response.write will show everything on the same line. Try this code...

<%@ language= "VBscript" %>
<% Option Explicit
Dim objMymail
Dim strBody

Set objMymail = Server.CreateObject("CDONTS.NewMail")
objMymail.To= "
mailto:sales@connexus.com - "
objMymail.From= request.form("Email")
objMymail.Subject = "Online Contact Form"
objMymail.Subject = "Online Contact Form"
strBody  = "Interested in Purchasing a Pre-Owned Mercedes or BMW: " & request.form("Purchasing") & vbcrlf & "Interested in BACK TRADING your car (Car + Cash): " & request.form("Backtrading") & vbcrlf & "Interested in a Trade-In Evaluation: " & request.form("Evaluation") & vbcrlf & "Name: " & request.form("Name") & vbcrlf & "Company: " & request.form("Company")  & vbcrlf & "Phone: " & request.form("Phone") & vbcrlf & "Fax: " & request.form("Fax")  & vbcrlf & "Comments: " & request.form ("Comments")   
objMymail.Body = strBody
objMymail.Send
Response.Redirect("thanks1.asp")
Set objMymail=Nothing
%>

NewMail is a CDO method name, you probably shouldn't use the same name for an object you create. Changed it to objMymail.

If the email doesn't display appropriate line breaks:

  1. Try replacing vbCRFL with chr(13) & chr(10)
  2. If it still doesn't work, check your form and any java validation script (you may want to post the code here).
  3. Try looking at the email with a different email client.

 



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: walrus
Date Posted: 21 April 2004 at 8:06pm

Thanks Dpyers for going to so much trouble. I have continued testing and have just noticed a message in Outlook saying that extra line breaks were removed and to click to restore. All looks fine once restored but don't know if this is an Outlook default or what??? Thanks again.

Cheers
Lance



Posted By: dpyers
Date Posted: 21 April 2004 at 8:15pm

Foir others who may be using the same email client, you may want to try changing the Carriage-Return plus Line-Feed to just a Line-Feed by replacing vbCRLF with chr(10) - the ansi cde for a linefeed. e.g.

"Line 1" & chr(10) & "Line 2"



-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net