RichTextBox.Text is formated in HTML [modified]
-
Hello, How can I get all contents in RichTextBox and convert it to HTML format My RichTextBox on winform. And I want to get it contents in HTML to sent it to my mail. But it doesn't work properly when I set BodyFormat = HTML. Thank you, ACB -- modified at 12:25 Thursday 26th October, 2006
ngh
-
Hello, How can I get all contents in RichTextBox and convert it to HTML format My RichTextBox on winform. And I want to get it contents in HTML to sent it to my mail. But it doesn't work properly when I set BodyFormat = HTML. Thank you, ACB -- modified at 12:25 Thursday 26th October, 2006
ngh
-
Hello, How can I get all contents in RichTextBox and convert it to HTML format My RichTextBox on winform. And I want to get it contents in HTML to sent it to my mail. But it doesn't work properly when I set BodyFormat = HTML. Thank you, ACB -- modified at 12:25 Thursday 26th October, 2006
ngh
I've used this in the past:
public string ToHTML(RichTextBox Box) { string sReturn; long lColour; bool bBold; bool bItalic; string sFont; long lSize; long lOldSelStart; long lOldSelLength; long a; //Initial box setup { lOldSelStart = Box.SelStart; lOldSelLength = Box.SelLength; Box.SelStart = 0; Box.SelLength = 1; } //Initial text sReturn = ""; //Inital paramaters lColour = Box.SelColor; bBold = Box.SelBold; bItalic = Box.SelItalic; sFont = Box.SelFontName; lSize = Box.SelFontSize; //Initial font setup sReturn = sReturn + ""; //Initial bold setup if (Box.SelBold == true) { sReturn = sReturn + "**"; } //Initial italic setup if (Box.SelItalic == true) { sReturn = sReturn + "_"; } //Append new character sReturn = sReturn + Strings.Mid(Box.Text, 1, 1); for (a = 2; a <= Strings.Len(Box.Text); a++) { //Set up reading paramater { Box.SelStart = a - 1; Box.SelLength = 1; } //Check for updated font tage if (Box.SelColor != lColour | Box.SelFontName != sFont | Conversion.Int(Box.SelFontSize) != lSize) { sReturn = sReturn + "_****_"; } //Check for changed boldness if (Box.SelBold != bBold) { if (Box.SelBold == false) { sReturn = sReturn + "_**_"; } else { sReturn = sReturn + "**"; } } //Check for changed italics if (Box.SelItalic != bItalic) { if (Box.SelItalic == false) { sReturn = sReturn + "**_**"; } else { sReturn = sReturn + "_"; } } sReturn = sReturn + Strings.Mid(Box.Text, a, 1); //Update paramaters lColour = Box.SelColor; bBold = Box.SelBold; bItalic = Box.SelItalic; sFont = Box.SelFontName; lSize = Box.SelFontSize; } //Check ending bold and italic if (bBold == true) sReturn = sReturn + "_**_"; if (bItalic == true) sReturn = sReturn + "_"; //Terminate HTML sReturn = sReturn + ""; //Restore box values { Box.SelStart = lOldSelStart; Box.SelLength = lOldSelLength; } return sReturn; //Return value }