You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Docs复选清单联动邮件通知功能实现咨询(基于Google Apps Script)

Yes, You Can Build This with 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+9 on Windows, Cmd+Shift+9 on 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.gs file. Delete the existing sample code (it’s just a placeholder myFunction()).

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 emailSubject and emailBody to 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:

  1. In the Apps Script editor, click the clock icon (Triggers) on the left sidebar
  2. Click Add Trigger (blue button in the bottom right)
  3. 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
  4. 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 16:09:10