Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Everyone.

I have been developed a small smtp Windows application in vb.net, .net 4 framework. ihave read the following article How to Send Mails from your GMAIL Account through VB.NET or C#. Windows Programming, with a Bit of Customization[^], with a Bit of Customization[^] and used snippets of codes to get the main funcationality of the program.

An issue I am stuck with and I have searched multple places on the net with no luck, is I am using a richtextbox for the main message text box (txtmessge) but when I send the message in HTML view, it doesnt retain the formatting properties, is it achievable to have a message sent as it formatted in the richtextbox.

I have review many article with no success of an apporiate code they all seem to raise formatting issues.

Converting RTF to HTML in VB.NET the Easy Way[^]

And after previous post, Simon has informed me that Outlook 2007 on has changed its way it reads stylesheets.

Also be aware that outlook 2007 onwards has changed the ways that it reads HTML emails.

you will need to embed images rather than add them as HTML tag. Also they have changed the way that it reads StyleSheets.

microsoft breaks html email rendering in outlook[^]


I believe this is where the issue alies in the code:
VB
Dim htmlview As String
      Dim messagebyuser As String = txtmessage.Text
      Dim locateS As String = "C:\logo.jpg"
 htmlview = messagebyuser

or will I have to build the message into a html structure?

any help would be appericated. =)
Posted
Updated 20-Feb-11 0:10am
v2

1 solution

Take a look at HTML e-mail[^] on wikipedia.

Converting RTF to HTML in VB.NET the Easy Way[^] requires word to be installed on the computer, and if that's a requirement - I'd just drop the rtf editor and use word directly - possibly embeding it inside the application as a control.

Basically you message will have to be rendered as HTML, preferably referencing nothing that's not part of the message for rendering purposes.

You could do worse than using DevExpress Rich Text Editor[^] as a replacement for the standard .Net rtf editor - it knows about html.

If you want to keep on using the standard .Net rtf editor - you'll be able to access the
Text Object Model[^], and can roll your own html exporter using this unmanaged API.

If you don't have a lot of time on your hands, shopping around for an existing solution would probably be the best way to solve your problem.

Regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 20-Feb-11 15:14pm    
Quite detailed, my 5.
--SA
Espen Harlinn 20-Feb-11 15:24pm    
Thank you SAKryukov!

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