HTML conversion adding span style="background.color:bla

  • Hi
    I'm having a problem when i convert RTF to HTML and sending the result in the body of an email. I use the method
    emailBody := rte.AsANSIString('HTML-nomergefields');
    We set the mime type in the email to html
    We are getting parts of the email blacked out. In View Source I find:

    Code
    <div style="text-align:justify;"><span style="background.color:black;"><font size=2>We have made the following changes in order to process your enrolment.</font></div>

    Looking at the RTF I can see not reason for this

    Code
    These papers are not available for the following reasons:\par  \pard\plain\qj\plain\fs20\par  \pard\plain\qj\plain\fs20\cb4\i\par  \pard\plain\qj\plain\fs20\par  \pard\plain\qj\plain\fs20\par  \plain\fs20\cb0 We have made the following changes in order to process your enrolment.\par  \pard\plain\qj\plain\fs20\cb4\par  \tx1694\tx3402\tx5129\plain\fs20 Paper\tab Semester\tab Location

    Some versions of MS Outlook black out the enclosed text other versions ignore it and so you can see the text
    Can you help with this.[/code]

  • Removing all background colors does solve this particular problem.
    And because some versions of Outlook seem not to respond to back.color style. It will do for now. However, some users say they want font background for emphises, with the hope that MS fixes the bug in Outlook
    There is a bug in WPIOHTML.TWPHTMLWriter.UpdateCharAttr
    that is converting \cb0 to background.color:black.
    In debug -
    if FCharAttr.GetBGColor(aColor) line 1383
    returns aColor of 0
    and WPColorToString(aColor) returns black
    the is what FCharAttr looks like for cb0
    ((358, (0, 1, 1000, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0)), False, (0, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)))
    here is what FCharAttr looks like for cb15 which is font background color = black - also using font color = white
    ((390, (0, 1, 1000, 0, 0, 0, 0, 12, 15, 0, 0, 0, 0, 0, 0, 0)), False, (0, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)))

    FCharAttr.GetBGColor(aColor) is grabing correct attribute.

    I think the problem is in where clBlack is defined twice. the First one should be clNone line 587 in unit WPRTEDefs

    Code
    WPStandardColors: array[0..15] of TColor =
      (clBlack, clRed, clGreen, clBlue, clYellow,
        clFuchsia, clPurple, clMaroon, clLime, clAqua, clTeal, clNavy,
        clWhite, clLtGray, clGray, clBlack);

    This is used in TWPRTFProps.Init to fill the array FPaletteEntries.

    What do you think?