Forum Moderators: phranque

Message Too Old, No Replies

Preserving newline characters

         

zxk105

9:28 pm on Nov 19, 2004 (gmt 0)

10+ Year Member



I am developing a site using VB.NET. I just finished making the online contact form that has a text area. The way I did this was with this code:

<asp:TextBox id="txtComments" runat="server" columns="35" rows="8" textmode="MultiLine"></asp:TextBox>

Now, everything works fine and it gets emailed. However, the message in the text area gets rid of the newline characters and presents everything in one line, even when I use multiple lines to type in the message.

Why is this happening? How can I make sure that the message can keep the newline characters?

Thanks

SuperLite17

7:35 am on Nov 20, 2004 (gmt 0)

10+ Year Member



Try something like this:

mytextarea=request.form("txtComments")

response.write( replace(mytextarea, "\n","System.Environment.NewLine") )

:)

SuperLite17

11:53 am on Nov 20, 2004 (gmt 0)

10+ Year Member



Hello again zxk105,

If your mailObj.BodyFormat = MailFormat.Html
Then it should work like this:

mailObj.Body = replace(txtComments.text, System.Environment.NewLine, "<br>")

OR

If your mailObj.BodyFormat = MailFormat.Text
try this:

mailObj.Body = replace(EmailBody.text, System.Environment.NewLine, "\n")

Hope that helps clarify my previous post better.

zxk105

4:15 am on Nov 22, 2004 (gmt 0)

10+ Year Member



Yup, I did some more research just after I posted my problem and I found an example of the .replace function. I am using HTML so I replaced the Newline character with <br /> and it showed up in the email the way I wanted it. Thanks for your reply though!