1. Enable Extended Mail Merge in User interface.
2. Create Mail Merge Template document.
3. To get the template merge fields, use the below link
https://<yourdomain>.my.salesforce.com/servlet/servlet.SForceMailMerge?id=<SalesforceRecordId>
4. To enter the merge field use the below steps.
i. Go to Quick Parts –> Field.
ii. Select MergeField and enter the Field name.
Check the sample below.
5. Go to Communication Templates –> Mail Merge Templates.
6. Click New Template button.
7. Select the template created and Save it.
8. Go to Leads tab and select Mass Mail Merge under tools.
9. Select the lead records.
10. Select Documents or Envelope or Label. I have selected Documents since I created Documents template.
11. Click Finish.
12. Check your email for the document.