...

View Full Version : Interlacing HTML in CDONTS



SteveH
10-12-2007, 12:32 PM
Hello

I have the following CDONTS script:

Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.BodyFormat = 0
ObjMail.MailFormat = 0
ObjMail.To = "myEmail@whatever.com"
ObjMail.CC = sEmailAddress
ObjMail.From = sEmailAddress
ObjMail.Subject = "Feedback"
ObjMail.Body = sFullNameTitle & vbcrlf&_
sFullName & vbcrlf&_
sEmailTitle & vbcrlf&_
sEmailAddress & vbcrlf&_
sBusinessTitle & vbcrlf&_
sBusinessName & vbcrlf&_
sCountryTitle & vbcrlf&_
sCountryName & vbcrlf&_
MessageName & vbcrlf&_
MessageTitle
ObjMail.Send
Set ObjMail = Nothing
%>

The visitor to the site fills in an online form and the script above sends a copy of the information input to the Webmaster and the site visitor himself.

This is the format it is received in:

Fullname harry totti Email tomas@hotmail.com Business Nowt Country Nowhere Message me

How can I create a far more attractive message, such as:

Fullname
His name
Email

etc to appear as in a short list? Where would I insert the HTML in the above CDONTS code?

Many thanks for any advice.

Steve

BarrMan
10-12-2007, 12:56 PM
ObjMail.Body => ObjMail.HTMLBody

SteveH
10-12-2007, 01:16 PM
Hello BarrMan

Thank you for your message.

So I insert ObjMail.Body => ObjMail.HTMLBody as follows?

Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.BodyFormat = 0
ObjMail.MailFormat = 0
ObjMail.To = "myEmail@whatever.com"
ObjMail.CC = sEmailAddress
ObjMail.From = sEmailAddress
ObjMail.Subject = "Feedback"
ObjMail.HTMLBody
ObjMail.Body = sFullNameTitle & vbcrlf&_
sFullName & vbcrlf&_
sEmailTitle & vbcrlf&_
sEmailAddress & vbcrlf&_
sBusinessTitle & vbcrlf&_
sBusinessName & vbcrlf&_
sCountryTitle & vbcrlf&_
sCountryName & vbcrlf&_
MessageName & vbcrlf&_
MessageTitle
ObjMail.Send
Set ObjMail = Nothing

But what about my HTML elements such as font size, colour, bold or not, list, etc?

Thanks again.

Steve

Spudhead
10-12-2007, 06:05 PM
sBody = "<b>Fullname</b>: " & sFullName & "<br/>" & vbcrlf &_
"<b>Email</b>: " & sEmailAddress & "<br/>" & vbcrlf &_

[etc etc]

ObjMail.HTMLBody = sBody

SteveH
10-12-2007, 11:22 PM
Hello Spudhead

Thank you for your post.

I'll try it over the weekend and post back here. Your code seems logical, so let's hope it works!

Cheers

Steve

SteveH
10-15-2007, 01:19 PM
Hello

This is the code I now have:

<%

Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.BodyFormat = 0
ObjMail.MailFormat = 0
ObjMail.HTMLBody = sBody
ObjMail.To = "whatever@whatever.com"
ObjMail.CC = sEmailAddress
ObjMail.From = sEmailAddress
ObjMail.Subject = "Feedback"
ObjMail.Body = sFullNameTitle & vbcrlf&_
sFullName & vbcrlf&_
sEmailTitle & vbcrlf&_
sEmailAddress & vbcrlf&_
sBusinessTitle & vbcrlf&_
sBusinessName & vbcrlf&_
sCountryTitle & vbcrlf&_
sCountryName & vbcrlf&_
MessageName & vbcrlf&_
MessageTitle
ObjMail.Send
Set ObjMail = Nothing

sBody = "<b>Fullname</b>: " & sFullName & "<br/>" & vbcrlf &_
"<b>Email</b>: " & sEmailAddress & "<br/>" & vbcrlf &_
"<b>Business</b>: " & sBusinessName & "<br/>" & vbcrlf &_
"<b>Country</b>: " & sCountryName & "<br/>" & vbcrlf &_
"<b>Message</b>: " & sMessageName & "<br/>" & vbcrlf &_
%>

It is generating the following error:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'HTMLBody'

/file.asp, line 68

I would be grateful for any further suggestions - the final part of the script does not look right to me, though I do not know why!

Cheers again.

Steve

Spudhead
10-15-2007, 02:40 PM
Take out the .HTMLBody line - just set the body with the .Body line

bluegenel
10-15-2007, 02:46 PM
Hi SteveH

You really should be using CDOSYS. However, try the following:

The code below should be in a separate .asp page, name this page how you want.

Your main form submits to this page.

The 'request.form("sfields")' relate to the fields on your main form.

I have tested the code below and it works. Good luck.

Dim ObjMail
Dim strHTML
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
strHTML = strHTML & "<html><head><title>title goes here</title></head>"
strHTML = strHTML & "<body>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sFullName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sEmailTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sEmailAddress")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sBusinessTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sBusinessName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sCountryTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sCountryName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"
strHTML = strHTML & "</body></html>"


ObjMail.From = request.form("sEmailAddress")
ObjMail.To = "whatever@whatever.com"
ObjMail.CC = request.form("sEmailAddress")
ObjMail.Subject = "Feedback"
ObjMail.BodyFormat = 0
ObjMail.MailFormat = 0
ObjMail.Body = strHTML
ObjMail.Send
Set ObjMail = Nothing


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<title>Home Page</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>
<body>



<p>Thank You</p>



</body>

</html>

SteveH
10-15-2007, 04:56 PM
Hello Bluegenel

Many thanks for your reply - and your work!!

I will try the script tonight and let you know how I get on, but I will probably not be able to use it on a separate page.

manyt hanks again for all your work.

Steve

SteveH
10-16-2007, 10:47 PM
Hello Bluegenel

I have pasted in this:

Dim ObjMail
Dim strHTML
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
strHTML = strHTML & "<html><head><title>title goes here</title></head>"
strHTML = strHTML & "<body>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sFullName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sEmailTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sEmailAddress")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sBusinessTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sBusinessName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sCountryTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sCountryName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"
strHTML = strHTML & "</body></html>"


ObjMail.From = request.form("sEmailAddress")
ObjMail.To = "myemail@myinbox.com"
ObjMail.CC = request.form("sEmailAddress")
ObjMail.Subject = "Feedback"
ObjMail.BodyFormat = 0
ObjMail.MailFormat = 0
ObjMail.Body = strHTML
ObjMail.Send
Set ObjMail = Nothing

Nothing else.

I already have a personalised 'thank you' on the site itself which works, so I have removed your HTML 'thank you' message.

However, now there is no message sent at all to mye.mail@myinbox.com

Please advise

Thanks.

Steve

bluegenel
10-22-2007, 09:44 AM
Hi SteveH

Sorry, my mistake.

Try enclosing the script with <% at the beginning and %> at the end. As follows:

<%

Dim ObjMail
Dim strHTML
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
strHTML = strHTML & "<html><head><title>title goes here</title></head>"
strHTML = strHTML & "<body>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sFullName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sEmailTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sEmailAddress")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sBusinessTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sBusinessName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sCountryTitle")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"

strHTML = strHTML & "<tr>"
strHTML = strHTML & "<td>"
strHTML = strHTML & "<font face=Arial size=2>"
strHTML = strHTML & request.form("sCountryName")
strHTML = strHTML & "</td>"
strHTML = strHTML & "</tr>"
strHTML = strHTML & "</body></html>"


ObjMail.From = request.form("sEmailAddress")
ObjMail.To = "myemail@myinbox.com"
ObjMail.CC = request.form("sEmailAddress")
ObjMail.Subject = "Feedback"
ObjMail.BodyFormat = 0
ObjMail.MailFormat = 0
ObjMail.Body = strHTML
ObjMail.Send
Set ObjMail = Nothing

%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum