Reputation: 1438
I'm trying to send Email where content is a rtf document in database (column BLOB).
So, I get my document in byte type from my DB, but then I don't know how to convert the rtf content into a readable text for an Email.
byte[] text = itm.Doc;
body= "<html><body>";
using (var file = new MemoryStream(text))
using (var reader = new StreamReader(file))
{
reader.BaseStream.Seek(0, SeekOrigin.Begin);
while (!reader.EndOfStream)
{
body+= reader.ReadLine();
}
}
But this of course, give me a rtf text, as the actual content of 'byte[] text'.
Can I convert my byte, containing rtf, to a byte containg pdf?
Thank you.
Upvotes: 1
Views: 3369
Reputation: 7475
Here is the guide to convert rtf to plain text:
http://msdn.microsoft.com/en-us/library/vstudio/cc488002.aspx
Update:
Try StreamReader.ReadToEnd()
like this:
using (var reader = new StreamReader(file))
{
reader.BaseStream.Seek(0, SeekOrigin.Begin);
body += reader.ReadToEnd();
}
rtBox.Rtf = body;
string[] lines = rtBox.Lines;
mail.Body = "<html><body>" + string.Join("<br/>", lines) + "</body></html>";
Upvotes: 1