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!

Email string with variable

Status
Not open for further replies.

MyGahp

Programmer
Sep 2, 2008
1
GB
Hello,

To some this will be easy, and I will be ashamed of my lack of knowledge, but...

I've got the following code.

Set myMail=CreateObject("CDO.Message")
myMail.Subject="Register interest"
myMail.From="some@emailaddy"
myMail.To="some@email"
myMail.TextBody=response.write("Name: " & fullname & "Address: "& address & "Email: " & email & "Name of Degree: " & degree & "Graduation Date: " & ddate & "Degree content: " & content & "Specialism: " & spec)
myMail.Send
Set myMail=nothing


when the mail gets sent, the email is blank (the heading and from do show, just the content is blank).

What am I missing? The response.write on it's own works, its just doesn't work assigning it to a variable. How can I get this to work?

Also, does anyone know how I can format the response.write to put line breaks in it? something like \n in php.

Thank you
 
Get rid of the response.write.

Code:
myMail.TextBody="Name: " & fullname & "Address: "& address & "Email: " & email & "Name of Degree: " & degree & "Graduation Date: " & ddate & "Degree content: " & content & "Specialism: " & spec

As for lines, appending vbCrLf (carriage return and line feed) should fix that:

Code:
myMail.TextBody="Name: " & fullname & vbCrLf & _
   "Address: "& address & vbCrLf & _
   "Email: " & email & vbCrLf & _
   "Name of Degree: " & degree & vbCrLf & _
   "Graduation Date: " & ddate & vbCrLf & _
   "Degree content: " & content & vbCrLf & _
   "Specialism: " & spec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top