Mail merge does not populate fields inside INCLUDETEXT using C#

What i’m trying to do (seems to be) a pretty standard server-side letter merge. It’s most of the way to working however what i’m getting stuck on is have a single “payment terms” page that is included by reference in every letter that needs one, rather than putting it directly into the template word document (using an INCLUDETEXT field). The file seems to be included correctly, but calling doc.MailMerge.Execute() doesn’t replace the MERGEFIELD fields in the included document.


Is this sort of usage supported directly in Aspose.Words? If so, what examples or classes should I be looking at? If not, is this likely something that would get added?

Thanks in advance for your help.

Regards,
Jon



Hi Jon,

Thanks for your query. As per my understanding you are trying to use following mail merge with include text. If not, please share some more detail about your issue along with document.

{INCLUDETEXT { MERGEFIELD fieldname}}

Hey Tahir,


Sorry thats not quite what I mean. Apologies for not being clear.

What i mean is that there are two files (i’ll call them letter.docx and payments.docx).

Letter.docx looks like :-
"""
{ MERGEFIELD Address }

Hello { MERGEFIELD Name }

Letter text goes here.

Regards,
Friendly Company
{ INCLUDETEXT “/payments.docx” }
""“

and payments.docx looks like :-
”"“
To make a payment please -

Foo biller code :- { MERGEFIELD FooPayment_biller }
Foo payment reference :- { MERGEFIELD FooPayment_ref }
”""

The problem is that payments.docx includes just fine but shows the MERGEFIELDs, not the data that they should have been replaced with. Payments.docx works fine individually, it’s only when its included from letters.docx that it doesn’t merge.

The goal here is to have a standard payment page for a broad range of letters that we send out so rather than having to update every template with a change to the payment page we change it in one place and everyone of them gets updated.

Regards,
Jon

Hi Jon,

Thanks for sharing the more information. I have managed to reproduce the same problem at my end. I have logged this issue in our issue tracking system and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,

I am experiencing the same problem. Any idea on when a fix will be available?

Kind Regards
James

Hi James,

Thanks for your query. I have verified the status of this issue from our issue tracking system and like to share with you that this issue is pending for analysis. After analysis, we will be in the position to share any ETA with you.

We apologize for your inconvenience.

James,

If you're interested, you can work around the issue (for now) by removing the Field markers (including everything between FieldStart and FieldSeparator) for all IncludeText mergefields.

Basically this works because the actual merge field looks like :-

FieldStart
Actual Command (as text generally)
FieldSeparator
Preview
FieldEnd

It's not the best of solutions (i don't think it would handle nested IncludeText fields without a lot of effort or possibly a recursive solution) but it gets the job done until such time as a proper fix comes out. Note that when you're iterating through FieldStart nodes, make sure you turn the NodeCollection from GetChildNodes into a concrete collection (i use ToArray) as otherwise you appear to invalidate the NodeCollection by deleting a node (meaning it will only resolve a single includetext reference).

Hi Jon,

Thanks for sharing the workaround. I have tried the shared workaround and have found that this do not work with attached documents. We always appreciate positive feedback form our customers.

Same problem here. Any idea on when a fix will be released?

Hi Jeff,

Thanks for your inquiry. I have verified the status of this issue from our issue tracking system and like to share with you that this issue is under analysis phase. At the moment, I can’t provide you the ETA for this issue. However, we will inform you via this forum thread as soon as it’s resolved.

Sorry for the inconvenience.

Thanks for letting me know.

The issues you have found earlier (filed as WORDSNET-6201) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.