HTML Email Editor in a Windows Forms Application

By : John
Source: Stackoverflow.com
Question!

We are looking for a WYSIWYG editor control for our windows application (vb.net or c#) so that users can design HTML emails (to send using the SMTP objects in the dot net framework) before sending.

Currently all the available editors we can find have one of the following issues:

a)They rely on mshtml.dll or the web browser control which as proven for us to be unreliable as the html code and the editor get out of sync under windows 2000 (IE6)

b)They are web based not a windows form control

c)They place styles in the head of the document (see note below).

Unfortunately as this HTML email article descries the only sure way of making HTML emails to work with styles is to use them inline which now seems to be unsupported in many editors.

Does any one have any experience in this or could suggest a solution?

By : John


Answers

It's my first contribution.

You can use a RichTextBox. The RTF format is more than enough to create emails.

I recently wrote about how to load and save to hard disk, the contents of a RichTextBox.

Allows Copy and Paste. It's simple to use and with few buttons you can create your own commands.

With RichTextBox1 
    .SelStart = 0 
    .SelLength = Len (. Text) 
    .SelColor = vbRed
End With

Example for loading and saving.

http://danielcatala.wordpress.com/2014/01/30/como-cargar-y-guardar-archivos-richtext-con-wpf/

Private Sub btnCarga(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click

    Dim archivoCarga As New StreamReader("prueba.rtf")
    With RichTextBox1
        .Selection.Select(.Document.ContentStart, RichTextBox1.Document.ContentEnd)
        .Selection.Load(archivoCarga.BaseStream, System.Windows.DataFormats.Rtf)
    End With
End Sub

Private Sub btnGuarda(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click

    Dim archivoSalida As New StreamWriter("prueba.rtf")
    Dim bs As Stream = archivoSalida.BaseStream

    With RichTextBox1
        .Selection.Select(RichTextBox1.Document.ContentStart,     RichTextBox1.Document.ContentEnd)
        .Selection.Save(bs, System.Windows.DataFormats.Rtf)
    End With
End Sub


You can try .NET Win HTML Editor Control from SpiceLogic,

http://www.spicelogic.com/Products/NET-Win-HTML-Editor-Control-8

Their component can embed all local images and return .NET MailMessage object which is very handy for developing email client.



This video can help you solving your question :)
By: admin