Home > Software design >  How to replace "Tab" sign and multiple spaces so that they show correctly in HTML mail bod
How to replace "Tab" sign and multiple spaces so that they show correctly in HTML mail bod

Time:03-01

I am looking for a way to replace RichTextBox multiple spaces and tabs with html characters so that they are shown correctly in Outlook .HTML mail body.

I tried using that for tabs:

msg = msg.Replace(vbTab, "<td>")

But it does not work. I do now know what to do for multiple spaces - I do not find any <> code to use in this code:

msg = msg.Replace("  ", "<what to put here?>")

All ideas will be greatly appreciated!

CodePudding user response:

The HTML entity for space is &nbsp; and the entity for tab is &emsp;.

Here is how you would apply it to your RichTextBox:

Dim message = MyRichTextBox.Text.Replace(" ", "&nbsp;").Replace(ControlChars.Tab, "&emsp;")
  • Related