Click to See Complete Forum and Search --> : line breaks into text in a variable.


kleb
06-03-2004, 05:52 PM
Hello,
I'm trying to insert the following text and variables into another variable for email transmission as follows:-

Dim txt
txt = ("A new person has just registered. The details are : <br>" &_
"First Name : "&strFirst&"<br>" &_
"Last Name : "&strLast&"<br>" &_
"Email : "&strEmail&"<br>" &_
"Password : "&strPassword&"<br>" &_
"Hint : "&strHint&"<br>" &_
"Answer : "&strAnswer)

Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = "me@website.com"
Objmail.From = "meagain@website.com"
ObjMail.Subject = "New Registrant"
ObjMail.Body = txt
ObjMail.Send
Set ObjMail = Nothing

Everything sends ok and no errors are thrown. It's just that when I get the email with the userinput the email text is all in a straight line. I want the correct linebreaks to render the email text in list format. I'd appreciate if someone can correct my mistakes.

Thanks your help
kleb

lmf232s
06-03-2004, 08:20 PM
Not sure why that would not work but try this. This works for me.
("A new person has just registered. The details are : <br>" &_
"First Name : "&strFirst&"<br>" &_
"Last Name : "&strLast&"<br>" &_
"Email : "&strEmail&"<br>" &_
"Password : "&strPassword&"<br>" &_
"Hint : "&strHint&"<br>" &_
"Answer : "&strAnswer)



Dim ObjMail
Set ObjMail = Server.CreateObject("CDONTS.NewMail")
ObjMail.To = "me@website.com"
Objmail.From = "meagain@website.com"
ObjMail.Subject = "New Registrant"
MyBody = "A new person has just registered. The details are : " & vbCrLf
MyBody = MyBody & "First Name : " & strFirst & " & vbCrLf
MyBody = MyBody & "Last Name : "&strLast&" & vbCrLf
MyBody = MyBody & "Email : " & strEmail & " & vbCrlf
MyBody = MyBody & "Password " & strPassword & " & vbCrlf
MyBody = MyBody & "Hint : " & strHint & " & vbCrlf
MyBody = MyBody & "Answer " & strAnswer & " & vbCrlf
ObjMail.Body = MyBody
ObjMail.Send
Set ObjMail = Nothing

CrazyC115
06-03-2004, 10:08 PM
Originally posted by lmf232s
Not sure why that would not work but try this. This works for me....


Comes down to how you are sending the email... ie you can not use HTML tags in plain text formated email messages. They will just show up as <br> and not a line break.

How to send HTML Formated emails with the CDONTS.NewMail Object (http://www.devasp.com/samples/mail3.asp)

kleb
06-04-2004, 09:21 AM
Works perfectly !

A thousand thanks. Greatly appreciated.

Kleb