Can you do a mail merge in google docs free

While Google Docs doesn't have a built-in mail merge feature like Microsoft Word, you can still achieve a similar result using a combination of Google Sheets and Google Docs. Here's a workaround:

Step 1: Prepare your data in Google Sheets

Create a Google Sheet with the following columns:

Enter your data in these columns. Make sure to format the email addresses correctly.

Step 2: Create a Google Doc template

Create a new Google Doc and add the merge fields you want to use. For example, you can add placeholders like {{First Name}}, {{Last Name}}, {{Email Address}}, {{Merge Field 1}}, and {{Merge Field 2}}.

Step 3: Use Google Apps Script to merge the data

In your Google Sheet, go to Tools > Script editor. This will open the Google Apps Script editor.

Create a new script by clicking on the "Create" button. Name the script, for example, "Mail Merge".

In the script editor, paste the following code:

function mailMerge() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var doc = DocumentApp.openById("YOUR_DOC_ID");
  var body = doc.getBody();

  var dataRange = sheet.getDataRange();
  var data = dataRange.getValues();

  for (var i = 0; i < data.length; i++) {
    var row = data[i];
    var firstName = row[0];
    var lastName = row[1];
    var emailAddress = row[2];
    var mergeField1 = row[3];
    var mergeField2 = row[4];

    body.replaceText("{{First Name}}", firstName);
    body.replaceText("{{Last Name}}", lastName);
    body.replaceText("{{Email Address}}", emailAddress);
    body.replaceText("{{Merge Field 1}}", mergeField1);
    body.replaceText("{{Merge Field 2}}", mergeField2);

    var pdf = doc.getAs("application/pdf");
    var blob = pdf.getBlob();
    var file = DriveApp.createFile(blob);
    file.setName("Mail Merge - " + firstName + " " + lastName + ".pdf");
  }
}

Replace YOUR_DOC_ID with the ID of your Google Doc.

Step 4: Run the script and generate the merged documents

Go back to your Google Sheet and click on the "Run" button next to the script editor. This will run the script and generate a new PDF document for each row in your data.

The script will replace the merge fields in your Google Doc with the corresponding values from your Google Sheet and save each document as a PDF file in your Google Drive.

Limitations

While this workaround allows you to achieve a mail merge in Google Docs, there are some limitations to consider: