We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mail Merge removing Bookmarks

I am using Aspose.Words .Net to perform a mail merge. The mail merge contains IF fields. Inside the text of the IF fields I have some bookmarks. When I use the Cleanup Options the bookmarks are being removed.

Please can you help?

I have attached some source code and a sample document.

Hi Richard,

Thanks for your inquiry. I suggest you please read MailMergeCleanupOptions Enumeration from here:

Your document contains the bookmark inside the IF Field. The following code snippet removes the bookmark from IF Field. This is the correct behavior of Aspose.Words. Please exclude MailMergeCleanupOptions.RemoveContainingFields from CleanupOptions. This will solve your problem.

RemoveContainingFields : Specifies whether fields that contain merge fields (for example, IFs) should be removed from the document if the nested merge fields are removed.

document.MailMerge.CleanupOptions =
MailMergeCleanupOptions.RemoveUnusedFields |
MailMergeCleanupOptions.RemoveUnusedRegions |
MailMergeCleanupOptions.RemoveContainingFields |