Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a RichTextBox in WIndows application. where i can enter the formatted data into it. I save the data by

Dim rtfstr As String = RichTextBox1.Rtf.Replace("\'", "\\")

      messgae = rtfstr


i am saving the message in the database in RTF format as datatype nvarchar(MAX).

i am retrieving into the same textbox by querying the database and assigning it to the
same tetxtbox

RichTextBox1.Rtf
= message

What I have tried:

Now i want to send this message as a mailbody ..
for that i have written the below code

strsql = "select message from data"
Dim mailbody As String = dt.Rows(0)("message").ToString()


dim mailHTMLBody = "<html><body><pre style='font-family:inherit;'>" + message + " 
"


mail.ISBodyHTML = True

Then After sending the mail. In the mail body it is displaying the RTF Format.



can anyone suggest me for sending the rtf mail
Posted
Updated 12-Dec-17 23:48pm
v2
Comments
Jochen Arndt 13-Dec-17 3:08am    
You have to convert from RTF to HTML. Just embedding the RTF text by HTML tags won't work.

If you don't need formatting, use a normal text box instead and send as plain text or HTML (plain text can be embedded by pre tags or converted to HTML by replacing reserved characters and line feeds).
Member 13142345 13-Dec-17 5:45am    
I have searched the google for converting the rtf to html code. But i found the converters not the code. Some says use RTF parser. But it is not avilabel on visual studio 2008.

SO, can you advice me on this Please..
Jochen Arndt 13-Dec-17 5:52am    
Converting RTF to HTML is a quite complex task. There is no simple code to do that. The common solution is to use a library or an external tool.
Member 13142345 13-Dec-17 6:04am    
ok... Thank you Jochen for your answer...
Member 13142345 13-Dec-17 6:05am    
So, Is there any other suggestion to send the formatted text as an email body?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900