Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Online form - one field only 2

Status
Not open for further replies.

SteveHigh

Technical User
Jan 17, 2007
158
GB
Hello

I have greatly simplified this post, which is in two parts, so as to get at the root of the problem I am having with sending an HTML-formatted email in CDO.

I have an online form with one field only: (User's) Email

<%
Dim sEmailTitle,sEmailAddress

sEmailTitle = "Email"
sEmailAddress = Request.Form("Email")
Set myMail=CreateObject("CDO.Message")
myMail.From="theMaster@world1.com"
myMail.To="sEmailAddress"
myMail.Send
set myMail=nothing
%>

The email is sent to the appropriate email address (meaning 'sEmailAddress' works), but the site
visitor only gets this in his inbox:

Email

Why is his own email address not shown after this Email heading (especially in view of the fact that the server knows the address to deliver the message to)? All it has done is copy 'sEmailTitle'. It has neglected sEmailAddress when it comes to reproducing that address as it ought to have done.

The other part of this prickly issue concerns HTML-formatting. How can I format the word which he has received in his inbox, that is 'Email' so that it is, for instance, in 10pt Verdana with the
colour 42129B?

Many thanks for any help.

Steve
 
In the script above as posted, the value of variable sEmailTitle is not used in the email.

It could be sEmailTitle = "Donald Duck" and nothing would change about the email.
 
Hello Sheco

Thanks for your post.

Yes, I can see it now. I have corrected it to:

myMail.Subject="Your Submission"
myMail.From="whoever@whatever.com"
myMail.To=sEmailAddress
myMail.Cc="whoever@whatever.com"
myMail.Bcc="whoever@whatever.com"

myMail.TextBody="Message" & vbcrlf & vbcrlf & _


"Your copy. Please do not reply to this email" & vbcrlf & _

"Full name: " & sFullName & vbcrlf & _
"Email: " & sEmailAddress & vbcrlf & _
"Business: " & sBusinessName & vbcrlf & _
"Country: " & sCountryName & vbcrlf & _
"Message: " & MessageTitle & vbcrlf
myMail.Send
set myMail=nothing

%>

It works! I now get this in my inbox:

Message

Your copy. Please do not reply to this email
Full name: Harry Smith
Email: whoever@whatever.com
Business: Refuse
Country: UK
Message: Hi

Can I ask you, then, about where to place HTML formatting so that, for instance, Full name, Email, Business, etc are in a bold font so that these 'headings' stand out from the rest?

Many thanks.

Steve

 
If I remember correctly you would use a property named HTMLBody instead of TextBody.

And the string you assign has HTML embedded...

myMail.HTMLBody="Message" & vbcrlf & vbcrlf & _
"Your copy. Please do not reply to this email" & vbcrlf & _
"<B>Full name</B>: " & sFullName & vbcrlf & _
"<B>Email</B>: " & sEmailAddress & vbcrlf & _
"<B>Business</B>: " & sBusinessName & vbcrlf & _
"<B>Country</B>: " & sCountryName & vbcrlf & _
"<B>Message</B>: " & MessageTitle & vbcrlf


If it isnt HTMLBody it is something similar... I'm not sure of the property name.
 
Hello Sheco

Yes, it sort of works. The Name, Business, etc are in bold in the email which is sent from the site.

I have tried to build on this as follows:

"Please do not reply to this email" & vbcrlf & _
"<B><font face='verdana' size='2' color='navy'>Full name:</font></B> " & sFullName & vbcrlf & _ <br>
"<B>Email</B>: " & sEmailAddress & vbcrlf & _
"<B>Business</B>: " & sBusinessName & vbcrlf & _
"<B>Country</B>: " & sCountryName & vbcrlf & _
"<B>Message</B>: " & MessageTitle & vbcrlf

but now I am gettin an 'invalid character' message. I have also tried it with the usual "verdana" quotes and with double quotes ""verdana"", but I get error messages there, too.

Any ideas?

Steve


 
It looks like there is trailing b]<br>[/b] on the line with the name... it should be in quotes.
 
err. lemme try that again:

It looks like there is trailing <br> on the line with the name... it should be in quotes.
 
Hello Sheco

This is the error msg I get using '<br>'

Invalid character

vbcrlf & _ '<br>'
-----------^

and this is the error I get using "<br>"

vbcrlf & _ "<br>"
-----------^

The rest of the script is in single quotes:

"<B><font face='verdana' size='2' color='navy'>Full name:</font></B> " & sFullName & vbcrlf & _ "<br>"


Steve
 
That is because it is AFTER the line continuation character! Remove the existing underscore and add the full line continuation sequence after the "<br>"

Those 2 lines should look like
Code:
"<B><font face='verdana' size='2' color='navy'>Full name:</font></B> " & sFullName & vbcrlf & "<br>" &_
"<B>Email</B>: " & sEmailAddress & vbcrlf & _

You may need the other lines to contain <br> as well unless you want them all run on.


___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
I think that has done the trick, John...........Great.

Very many thanks to both of you.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top