Multi-line textbox vb.net

Soldato
Joined
20 Jan 2005
Posts
2,722
Location
Whitley Bay
Hi there,

This is probably a stupid question so I apologise in advance.

I'm writing code to pass information from a multi-line text box to a new email message.
When testing, I can enter text over several lines within the text box but the data that is passed to the email message is all on one line.

Is there a way of retaining the formatting of the text?

TIA

Si
:)
 
Need to look at your code to see where you are going wrong, there a a couple of different ways you could ensure newlines are maintained, seeing the code will allow us to choose the best option.
 
Not sure if it's a web page you're doing and it might not be what you need, but you could try doing a string replace on the textbox content:

Code:
Dim emailContent As String = yourTextBox.Text

emailContent = emailContent.Replace(VbCrLf, "<br />")

//code to send emailContent to your emailing code

This replaces the line feed characters present in the text box and replaces them with HTML break tags which the email should understand (you might need to specify the email format as HTML also).
 
Last edited:
Back
Top Bottom