HTML mailmerge fields losing fonts

  • Hi all,
    I'm using:
    Delphi 7
    WPTools 24.01.2007 V5.0 Release 22

    I add mailmerge fields using the TwpDefEditor, the only change I made is I set the DefaultIOFormat='HTML', when I mailmerge, I lose the font.

    HTML snippet BEFORE performing mailmerge:
    <mergefield><font>Responsible_Person_Name</font></mergefield>

    HTML snippet AFTER performing mailmerge:
    <mergefield>Doright, Dudley</mergefield>

    I've also tried doing the mailmerge two ways, with the OnGetMailMergeText event and using the TWPMMDataProvider component, with the same result.

    Am I neglecting to do something?

  • Upon reading the post, I need to disable the before/after HTML snippets:

    BEFORE Mailmerge:
    <mergefield name="Responsible_Person_Name"><font face="Arial" color="black">Responsible_Person_Name</font></mergefield>

    AFTER Mailmerge:
    <mergefield name="Responsible_Person_Name">Doright, Dudley</mergefield>

  • The distinction is lost on me. Shouldn't the mailmerge just replace the "Responsible_Person_Name" part, and not mess with the font part?

    I can programmatically set the font with Contents.MergeAttr.SetFontName('Arial') , but I want the font that the user intended, which I thought I could get with MergeAttr.GetFontName(x) before replacing the StringValue, but it's blank (event though the html before snippet shows it in there. Is the some Contents.Option that I need to have set differently?

    • Offizieller Beitrag

    Hi,

    >>The distinction is lost on me. Shouldn't the mailmerge just replace the "Responsible_Person_Name" part, and not mess with the font part? <<

    No, the merge process is not a replacement but an insertion process. The field is marked by the enclosing markers and those markers select the attribute of the text. This concept makes it possible to merge in text multiple times without destroying the form.

    See this HTML code:

    <div><mergefield name="Responsible_Person_Name"><font face="Arial" color="black" size="4">Responsible_Person_Name</font></mergefield></div>

    <div><font face="Arial" color="black" size="4"><mergefield name="Responsible_Person_Name">Responsible_Person_Name</mergefield></div></font>

    The first paragraph will not use a large font for the merged name, the second will.

    If you do not like this behavior you need to add some code to the even OnMailMergeGetText:

    Code
    if Contents.StartInspObject.EmbeddedText<>'' then // not empty!
        Contents.MergeAttr.CharAttr :=
           Contents.StartInspObject.ParentPar.CharAttr[
           Contents.StartInspObject.ParentPosInPar+1];

    This code will simply take the character attribute of the first character INSIDE the field and use it for the text it is about to merge in.

    Julian