WPCubed Product Support

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?

#1 ♥ 0
7.8k Views 2 users read 3 min

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>

#2 ♥ 0
support

Hi,

when you do mailmerge the attribute of the merge field is applied to the inserted text, not the attribute of the text inside the field.

So it is required that the font attribute is already set for the field object.

Julian

#3 ♥ 0

The font is set for the field object. It's arial, which is show in the before snippet above. Is it not?

#4 ♥ 0
support

Hi,

The font is set for the field object. It's arial, which is show in the before snippet above. Is it not?<<

No, the <font> tag is INSIDE the field, not before the field.

Julian

#5 ♥ 0

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?

#6 ♥ 0
support

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:

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

#7 ♥ 0
This category is archived. No new posts are possible.