+1 vote
by (190 points)

Hi, finally already move from trial to full version of SecureIMAP, this tools are great, and thanks for all your help. I can do what I need in shor time and it was really easy.

My application "reads" emails and for certain conditions it saves some content in database for processing (it's sale information). I'm think it would be great send a mail to the customer, I already create some simple answear and works fine.

As I notice I can send HTML messages, but the problem is creating them, someone knows some kind of editor or composer for create HTML messages in VB.NET for Windows Form applications?

Thanks for your time.


Applies to: Rebex Secure Mail

1 Answer

0 votes
by (13.0k points)

I would try one of the following:

1) Use the WinForms WebBrowser control in edit mode

Following VB.NET code is taken from Stackoverflow question: winforms html editor.

Me.WebBrowser1.Document.OpenNew(False).Write("<html><body><div id=""editable"">Edit this text</div></body></html>")

'turns off document body editing
For Each el As HtmlElement In Me.WebBrowser1.Document.All
    el.SetAttribute("unselectable", "on")
    el.SetAttribute("contenteditable", "false")

'turns on editable div editing
With Me.WebBrowser1.Document.Body.All("editable")
    .SetAttribute("width", Me.Width & "px")
    .SetAttribute("height", "100%")
    .SetAttribute("contenteditable", "true")
End With

'turns on edit mode
Me.WebBrowser1.ActiveXInstance.Document.DesignMode = "On"
'stops right click->Browse View
Me.WebBrowser1.IsWebBrowserContextMenuEnabled = False

Note that this control works only when Internet Explorer is installed. It also has some shortcomings, but it's free and it may be enough for basic editing. There is also a free (Ms-PL license) wrapper around the WebBrowser control at codeplex. I would use this when the end user's environment can be controlled (you need the IE installed) and in case that I need only a basic editing.

2) Try some supported commercial component

XStandard supports WinForms and has quite a good reputation. (I've not tested it personally). I would use it if I have to distribute the app to many users and/or when XHTML compliance is needed.

3) Use your mail client and save them to disk in EML format

Use your favorite mail client for composing HTML messages. Save the message to the server. Download message via the IMAP and save them to the dist as EML file. EML files are human readable (sort of) and can be used as a template. I would use it if I have to prepare only few emails and or if modification of the produced HTML (e.g. adding mass mailing merge fields) is required.

Tip: you can use IMAP Browser sample to get a message content in EML format. The Raw message tab shows the message in the EML format.