Every cycle, someone in your organisation opens a Word template, types a name, changes a date, exports a PDF, attaches it to an email, sends it, and does it again. For 30 people that is a lost day. For 300 it is a lost week, and somebody gets the wrong letter.
We automated exactly this for SPPG's admissions team: one click writes the letter, turns it into a PDF, emails it and files it. You can build a simpler version yourself, for free, with tools you already have: Google Sheets, Google Docs, Gmail and Drive. No paid software and no code experience needed. You will copy and paste one script.
What you will have at the end
- A Google Doc template with placeholders like <<Name>> and <<Programme>>
- A Google Sheet with one row per person
- A menu button that, for every row not yet done, writes the letter, saves a PDF to a Drive folder, emails it, and marks the row as sent with a link to the PDF
Step 1: make the template
Create a Google Doc and write your letter. Wherever something changes per person, type a placeholder in double angle brackets that matches a column name exactly: <<Name>>, <<Programme>>, <<StartDate>>.
Copy the document's ID from its address bar. It is the long string between /d/ and /edit.
Step 2: make the sheet
Create a Google Sheet. In row 1, add these columns:
- Name and Email (required)
- One column for every placeholder in your letter, spelled the same way
- Status and PDF, left empty: the script fills them in
Step 3: make a folder
Create a folder in Google Drive for the finished PDFs and copy its ID from the address bar (the string after /folders/).
Step 4: paste the script
In the sheet, open Extensions → Apps Script, delete what is there, and paste this. Put your own IDs and subject line at the top.
const TEMPLATE_ID = 'YOUR_TEMPLATE_DOC_ID';
const FOLDER_ID = 'YOUR_DRIVE_FOLDER_ID';
const SUBJECT = 'Your letter';
function onOpen() {
SpreadsheetApp.getUi().createMenu('Letters').addItem('Send letters', 'sendLetters').addToUi();
}
function sendLetters() {
const sheet = SpreadsheetApp.getActiveSheet();
const rows = sheet.getDataRange().getValues();
const header = rows.shift();
const col = (name) => header.indexOf(name);
const folder = DriveApp.getFolderById(FOLDER_ID);
const template = DriveApp.getFileById(TEMPLATE_ID);
rows.forEach((row, i) => {
if (row[col('Status')]) return; // already sent: skip it
if (MailApp.getRemainingDailyQuota() < 1) return; // out of email quota: stop for today
const name = row[col('Name')];
const copy = template.makeCopy('Letter - ' + name, folder);
const doc = DocumentApp.openById(copy.getId());
header.forEach((h, c) => doc.getBody().replaceText('<<' + h + '>>', String(row[c])));
doc.saveAndClose();
const pdf = folder.createFile(copy.getAs(MimeType.PDF)).setName('Letter - ' + name + '.pdf');
copy.setTrashed(true); // keep the PDF, bin the working copy
GmailApp.sendEmail(row[col('Email')], SUBJECT,
'Dear ' + name + ',\n\nPlease find your letter attached.\n\nWarm regards',
{ attachments: [pdf.getBlob()] });
sheet.getRange(i + 2, col('Status') + 1).setValue('Sent ' + new Date().toLocaleString());
sheet.getRange(i + 2, col('PDF') + 1).setValue(pdf.getUrl());
});
}Step 5: test on yourself first
Add one row with your own name and email. Save the script, reload the sheet, and a Letters menu appears. Click Letters → Send letters. Google will ask you to authorise the script the first time: it needs Docs, Drive and Gmail. Check the PDF in your inbox and in the folder. Only then add the real rows.
Why it is safe to run twice
This is the part most tutorials leave out. The script writes "Sent" on every row it finishes and skips any row that already says so. If it stops halfway (Apps Script stops any run after about six minutes, and free Gmail accounts have a daily sending limit), just click the button again. It carries on where it stopped, and nobody gets two letters. We wrote a whole piece on why this matters: the automation mistake that pays twice.
Good to know
- Daily limits. A free Gmail account can send to roughly 100 recipients a day from a script; Google Workspace accounts can send more. The script checks the remaining quota and stops cleanly.
- Two kinds of letter? Make two templates and add a Type column. Pick the template ID from that column. That is the main/provisional split in SPPG's version.
- Formatting. Placeholders keep the formatting of the text around them, so style them in the template.
- Privacy. The PDFs live in your Drive. Share the folder only with people who need it.
When to stop doing it yourself
This version runs when you click. When you want letters to go out the moment a decision is made in your CRM, with the record updated, the copy filed and a log of every send, that is a single workflow we build in a week or two.