'How to preserve multiline TextBox/RichTextBox new lines in HTML mail body
I am trying to preserve new lines from RichTextBox (or normal TextBox if RTB will not work) while copying the RichTextBox.Text to HTML body in my Outlook mail.
I have tried many things over last couple of hours and nothing works.
I store RichTextBox text in variable like that:
Dim msg as string = RichTextBox.Text
Then I tried many things, like using Replace():
msg = msg.Replace(Environment.NewLine, "<br>")
or other things (or other characters "\r\n") etc. and nothing works. The msg string when copied into Outlook HTMLbody is in one line without any change.
What am I missing in here? I have looked over SO for a few hours today and cannot find a solution.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
