Google Docs复选清单联动邮件通知功能实现咨询(基于Google Apps Script)
Absolutely—even with no coding background, you can set up a checkbox-triggered email system in Google Docs using Google Apps Script. Let me walk you through every step clearly:
Step 1: Set Up Your Checkbox List in Google Docs
First, create your checklist:
- Open a new or existing Google Doc
- To add a checkbox, click Insert > Checkbox (or use the shortcut
Ctrl+Shift+9on Windows,Cmd+Shift+9on Mac) - Type a label next to each checkbox (e.g., "Task for Marketing Team", "Client Follow-Up")—this label will help the script know which email to send to who.
Step 2: Open the Google Apps Script Editor
- In your Google Doc, click Extensions > Apps Script
- You’ll see a new tab with a default
Code.gsfile. Delete the existing sample code (it’s just a placeholdermyFunction()).
Step 3: Paste the Custom Script
Copy and paste this code into the editor. I’ve added comments to explain what each part does:
function sendEmailOnCheckboxCheck(e) { // Grab the element that was just edited const editedElement = e.range.getElement(); // Make sure the edited element is a checkbox if (editedElement.getType() === DocumentApp.ElementType.CHECKBOX) { const checkbox = editedElement.asCheckbox(); // Only trigger when the checkbox is CHECKED (skip unchecking) if (checkbox.isChecked()) { // Get the text label next to the checkbox const parentParagraph = checkbox.getParent().asParagraph(); const taskLabel = parentParagraph.getText().trim(); // --- Customize this section! --- // Map your task labels to email addresses let recipientEmail = ""; if (taskLabel.includes("Task for Marketing Team")) { recipientEmail = "marketing@yourcompany.com"; } else if (taskLabel.includes("Client Follow-Up")) { recipientEmail = "clientrelations@yourcompany.com"; } else if (taskLabel.includes("IT System Update")) { recipientEmail = "it@yourcompany.com"; } // Add more `else if` blocks for additional checkboxes/emails // Send the email if we have a valid recipient if (recipientEmail) { // Customize your email subject and body here const emailSubject = `New Task Notification: ${taskLabel}`; const emailBody = `Hi there,\n\nThe following task has been marked as complete:\n${taskLabel}\n\nBest regards,\nYour Google Doc Automation`; // Send the email using Gmail GmailApp.sendEmail(recipientEmail, emailSubject, emailBody); // Optional: Add a confirmation note to the doc (green checkmark text) parentParagraph.appendText(" ✅ Email sent!").setForegroundColor("#2E7D32"); } } } }
Customization Tips:
- Update the
taskLabel.includes("...")lines to match your actual checkbox labels and corresponding email addresses - Tweak the
emailSubjectandemailBodyto fit your tone and needs (add links, extra details, etc.)
Step 4: Set Up a Trigger to Run the Script
Since this script uses Gmail (which needs permission), we can’t use the default "simple" trigger. We need to create an installable trigger:
- In the Apps Script editor, click the clock icon (Triggers) on the left sidebar
- Click Add Trigger (blue button in the bottom right)
- Fill out the trigger settings like this:
- Choose which function to run:
sendEmailOnCheckboxCheck - Choose which deployment to run:
Head - Select event source:
From document - Select event type:
On edit
- Choose which function to run:
- Click Save—you’ll be prompted to authorize the script.
Handling Authorization:
Google will show a warning saying "This app isn’t verified"—don’t worry, this is normal for custom scripts:
- Click Advanced at the bottom of the warning
- Click Go to [Your Script Name] (unsafe)
- Click Allow to grant the script permission to access your doc and send emails.
Step 5: Test It Out!
Go back to your Google Doc, check one of the checkboxes, and wait a minute. The recipient should get an email, and you’ll see a green "✅ Email sent!" note added to the task in the doc.
Troubleshooting Tips
- If no email sends: Double-check that your task label matches exactly what’s in the script, and that you authorized the script correctly
- If the script errors: Open the Apps Script editor, click Executions on the left sidebar to see error details
- For multiple users: If others edit the doc, they won’t need to re-authorize—since you set up the trigger as the doc owner, the script will run under your permissions.
内容的提问来源于stack exchange,提问作者Scott

