correct, though if you set the content type of the emails to HTML.
if you change myMail.TextBody to myMail.HTMLBody
Main Topics
Browse All TopicsHi,
I'm working on a form using CDOSYS, what I need to do is to be able to send several variables with text and line breaks using "TextBody", full code below.
All of the asp form samples I have seen use examples such as: myMail.TextBody="This is a message."
Though I need something like this: myMail.TextBody="Message: EmailQuery \n<br> Age: EmailAge \n<br> Nationality: EmailNationality", etc
So that the resulting email would be nicely formatted as:
Message: contents of EmailQuery variable
Age: contents of EmaiAge variable
Nationality: contents of EmailNationality variable
Can someone help?
Thanks,
Al
This is the code I have:
<%
' email values to set in form
'-------------------------
' EmailName
' EmailSurname
' EmailSenders
' EmailSubject
' EmailQuery
' EmailAge
' EmailNationality
' set up email values
EmailName=request("EmailNa
EmailSurname=request("Emai
EmailSenders=request("Emai
EmailSubject=request("Emai
EmailQuery=request("EmailQ
EmailAge=request("EmailAge
EmailNationality=request("
if EmailName="" then
response.Write("<html><bod
response.End
end if
if EmailSenders="" then
response.Write("<html><bod
response.End
end if
if EmailSubject="" then
response.Write("<html><bod
response.End
end if
if EmailQuery="" then
response.Write("<html><bod
response.End
end if
Set myMail=CreateObject("CDO.M
myMail.Subject = EmailSubject
myMail.From = EmailName & "<" & EmailSenders & ">"
myMail.To = "me@mydomain.com"
myMail.Cc = "him@hisdomain.com"
myMail.TextBody = EmailQuery
myMail.Send
set myMail=nothing
' show thankyou page
if not request("thanksPage")="" then
response.Redirect(request(
else
response.write("<html><bod
end if
response.End
%>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi, thanks for you help.
I have tried this:
Set myMail=CreateObject("CDO.M
myMail.Subject = "Scholarship Application"
myMail.From = EmailName & "<" & EmailSenders & ">"
myMail.To = "me@mydomain.com"
myMail.Cc = "him@hisdomain.com"
myMail.HTMLBody="Name: EmailName " & vbCrlf & "Address: EmailAddress" & vbCrlf & "Senders email: EmailSenders" & vbCrlf & "Nationality: EmailNationality" & vbCrlf & "Age: EmailAge"
myMail.Send
set myMail=nothing
This is the output in the email:
Name: EmailName Address: EmailAddress Senders email: EmailSenders Nationality: EmailNationality Age: EmailAge
No formatting and it's not printing the values - only the variable name.
Any ideas?
Thanks,
Al
if you use want to sen hhtml format then use HTMLBody
myMail.HTMLBody="Name: EmailName " & "<br>" & "Address: EmailAddress" & "<br>" & "Senders email: EmailSenders" & "<br>" & "Nationality: EmailNationality" & "<br>"& "Age: EmailAge"
if you want to sent text format then use TextBody
myMail.TextBody="Name: EmailName " & vbCrlf & "Address: EmailAddress" & vbCrlf & "Senders email: EmailSenders" & vbCrlf & "Nationality: EmailNationality" & vbCrlf & "Age: EmailAge"
Thanks Nurbek, That's helped with the formatting, though the field values are still not being sent:
This is the email output:
Name: EmailName
Address: EmailAddress
Senders email: EmailSenders
Nationality: EmailNationality
Age: EmailAge
Should be:
Name: A Name
Address: an@email.com
Senders email: senders@email.com
Nationality: British
Age: 26
etc
k..change this:
Set myMail=CreateObject("CDO.M
myMail.Subject = "Scholarship Application"
myMail.From = EmailName & "<" & EmailSenders & ">"
myMail.To = "me@mydomain.com"
myMail.Cc = "him@hisdomain.com"
myMail.HTMLBody="Name: EmailName " & vbCrlf & "Address: EmailAddress" & vbCrlf & "Senders email: EmailSenders" & vbCrlf & "Nationality: EmailNationality" & vbCrlf & "Age: EmailAge"
to this:
Set myMail=CreateObject("CDO.M
myMail.Subject = "Scholarship Application"
myMail.From = EmailName & "<" & EmailSenders & ">"
myMail.To = "me@mydomain.com"
myMail.Cc = "him@hisdomain.com"
myMail.HTMLBody="Name: " & EmailName & "<br />Address: " & EmailAddress & "<br />Senders email: " & EmailSenders & "<br />Nationality: " & EmailNationality & "<br />Age: " & EmailAge
problem was you had your variables enclosed in the quotes with your fields, so it was send the name of variable instead of the variable.
If you notice, all I did was move them to the outside of the quotes (thus the values will show and not just the name of the variable) and added in <br /> (which is html line-break)
Business Accounts
Answer for Membership
by: nurbekPosted on 2006-05-24 at 05:52:11ID: 16750715
use vbCrlf
myMail.TextBody="Message: EmailQuery " & vbCrlf & "Age: EmailAge" & vbCrlf & "Nationality:"