tags:

views:

206

answers:

2

Since I need to send email by code, I'm currently using plan text but since outlook, by default, remove the extra line break it screw up my formatting and I don't want that, I tried to put my text into html but now the email is marked as spam.

My last choice is to move the text into rtf but now my question is.

What is the easiest way to move text into rtf?

There is no user interface.

The email doesn't contain complex stuff, only text and some extra line, which is my current issue with plain text and default setting of outlook.

And no, I cannot change the default setting of outlook.

+3  A: 

You need to add a reference to System.Windows.Forms and then use the RichTextBox:

string text = "your text here";
string rtfText = string.Empty;
using(RichTextBox rtf = new RichTextBox()) {
    rtf.Text = text;
    rtfText = rtf.Rtf;
}
J. Random Coder
that did the job but I should have looked before if the system.net.mail was actually supporting sending as RTF and it doesn't, it seem you need to play with interop (outlook or word) to do that and that is a big no for me.
Fredou
+2  A: 

If you don't want Outlook to mess with it at all, use MIME type "application/binary". You won't get to see the code in the preview pane any more -- is that important to you?

Liudvikas Bukys