Search code examples
htmloutlookrtf

Signature needs to be in RTF instead of HTML. Passing in from VB6 to Outlook


I was passing a string of HTML formatted text for a signature in VB6 to Outlook but on certain very old computers with very old versions of outlook it was running into a problem where hypens would start a new line, or if I used the tag to fix it then word wrap would be totally turned off.

I want to try to use RTF instead hoping that this will fix the problem. However I still have that signature that is in HTML and I need to pass it in as a string into Outlook using Rich Text formatting. I can't find any good resources on this or if it is even possible, whenever I try they show up with the escape commands and everything.

My current HTML string:

string = vbCrLf & vbCrLf & "<B><FONT face=Arial color=#365f91 size=2>" & _
                        strName & "</FONT>" & _
                        "<FONT face=Arial size=2><BR>" & _
                        "<I>" & strPosition & "</I>" & _
                        "</FONT></B><BR/><B><FONT face=Arial size=2>" & _
                        strAddress1 & "</FONT></B><BR/><FONT face=Arial size=1>" & _
                        strAddress2 & "<BR>" & strCity & ", " & _
                        strProvince & ", " & strPostalCode & _
                        "<BR>" & strCountry & "<BR>Office: " & strPhone & _
                        "<BR>" & strEmail & "<BR>www.website.com<BR>" & _
                        "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & _
                        "<I><FONT face=Arial size=2>" & strImageCaption & "</FONT>" & _
                        "<BR/><BR/><BR/></I><FONT face=Arial size=1>" & strDisclaimer & _
                        "</FONT></P>"

Anyone able to help me pass this in as rtf or know of anyway I could do this? Will be very appreciated!

EDIT: Alternatively if anyone knows how to fix the issue with word-wrap/line-breaking hyphens I would love that too.


Solution

  • This can be the RTF template idea, produced by wordpad and slightly altered. I assume you can mixin the VB stuff to replace the variable text.

    To get this:
    Hello
    postion
    My‑street
    Mystreet 2
    My city
    My disclaimer

    ( I don't how to do color in SO markup but in the RTF the first line in RED and My disclaimer is one point smaller)

    use this RTF:

    {\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fnil\fcharset0 Arial;}}
    {\colortbl ;\red255\green0\blue0;}
    \cf0\b\fs22 Hello\par
    \cf0\b0\i\fs24 postion\par
    \i0 My\_street\par
    Mystreet 2\par
    My city\par
    \fs22 My disclaimer\par
    \f1\par
    }
    

    between My and street I placed a non breaking hyphen, according to the RTF specs. In html the same could be achieved by using

    &#8209;