A library to perform mail merge on Microsoft Word .docx files using standard Python data structures. Currently at version 1.0.1, it supports Python >=3.7. The project is under active maintenance with no regular release cadence.
pip install docx-mailmerge2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Basic usage: Load a .docx template, merge fields, and save output.
Use standard MergeField in Word (Insert > Quick Parts > Field > MergeField).
Replace imports from 'docx-mailmerge' to 'docx-mailmerge2' (pip install).
Ensure images are inserted as InlineShapes (not floating). Use merge with dictionary: {'Image': 'path/to/image.png'}.Use document.merge(Field1='Value1') instead of document.merge('Value1', 'Value2').Run: pip install docx-mailmerge2. Then import as: from mailmerge import MailMerge.
Verify merge field names in template using document.get_merge_fields() and use identical case/spelling.
Open the template in Word, remove any complex formatting or tracked changes, save as a new .docx.