Forums
This topic is locked
Textarea fields and CDONTS
Posted 10 Dec 2004 19:26:08
1
has voted
10 Dec 2004 19:26:08 Robert Loverin posted:
I've created a page that e-mails the content of a form via CDONTS. I have a few textarea fields on it. Is there a way for me to retain the formatting of the textarea field in the e-mail message? For example, if a user writes a few sentences and uses hard returns to separate the lines, can I get the data to appear in the e-mail message the same way? Right now, the data appears in one long string. Replies
Replied 13 Dec 2004 12:33:38
13 Dec 2004 12:33:38 Lee Diggins replied:
Hi Robert
I'm assuming you're trying to send the email as HTML or at least view the email in html. You need to do a find/replace on your string something like:
Replace(myString,vbcrlf,"<br>"
or if you need to use this as a function, something like:
Function FormatText(strInputText)
dim i
dim v
dim strOutput
dim strText
strText = strInputText
strOutput = ""
for i = 1 to len(strText)
v=mid(strText,i,1)
if v=chr(13) then
strOutput=strOutput & "<br>"
else
strOutput=strOutput & v
end if
next
FormatText = strOutput
End Function
And call the function like so:
FormatText(myString)
Digga
Sharing Knowledge Saves Valuable Time!!!
I'm assuming you're trying to send the email as HTML or at least view the email in html. You need to do a find/replace on your string something like:
Replace(myString,vbcrlf,"<br>"

or if you need to use this as a function, something like:
Function FormatText(strInputText)
dim i
dim v
dim strOutput
dim strText
strText = strInputText
strOutput = ""
for i = 1 to len(strText)
v=mid(strText,i,1)
if v=chr(13) then
strOutput=strOutput & "<br>"
else
strOutput=strOutput & v
end if
next
FormatText = strOutput
End Function
And call the function like so:
FormatText(myString)
Digga
Sharing Knowledge Saves Valuable Time!!!