Effortlessly Duplicate Gmail Drafts: Boost Productivity with Google Sheets and Apps Script

“Have you ever wished for a feature to duplicate drafts created in Gmail, to manage your emails more efficiently?”

Unfortunately, Gmail doesn’t offer a built-in function to duplicate drafts, so you have to create a new draft each time and manually copy and paste the content.

This process is time-consuming and reduces productivity.

As a solution, you can automate the duplication of drafts by using Google Apps Script.

In this article, we’ll show you how to use Apps Script and Google Sheets to easily duplicate drafts as many times as needed.

This allows you to reuse drafts as templates, streamlining your daily workflow and boosting efficiency.

TOC

Example Output

Spreadsheet

Gmail Draft Screen

  • Specify Draft Emails to Duplicate in Google Sheets
    • Column A: Subject (Keyword to identify the draft)
    • Column B: Number of copies to duplicate
  • Run the script to duplicate the draft emails.

When you run the script, the drafts saved in Gmail are automatically duplicated the specified number of times.

This is especially useful when you need to copy frequently used templates.

Steps

STEP
Create a Draft in Gmail

Create the draft email that you want to duplicate.

  • Recipients (To, Cc, Bcc)
  • Subject
  • Body

(The email can be duplicated regardless of whether it is in HTML or plain text format.)

STEP
Prepare the Spreadsheet

Column A: Subject keyword to identify the draft (partial match)

Column B: Number of copies to duplicate

Enter the subject of the email drafts and the number of copies you want to duplicate into the spreadsheet.

The script references a sheet named “Email Draft Duplication” during execution.

Feel free to rename the sheet if needed, but ensure the script reflects the updated sheet name.

STEP
Open Apps Script Editor

Open a Google Spreadsheet and click on “Extensions” in the menu, then “Apps Script” to open the Apps Script editor.

STEP
Create the Script

Since the default function myFunction() {} is present, delete it and replace it with the script below.

function duplicateDraft() {
  const sheetName = "DraftDup"; // Shortened sheet name
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);

  if (!sheet) {
    Logger.log(`The specified sheet "${sheetName}" was not found.`);
    return;
  }

  const data = sheet.getDataRange().getValues(); // Retrieve the data from the sheet

  for (let i = 1; i < data.length; i++) { // Skip the first row (header)
    const subjectKeyword = data[i][0]; // Subject keyword
    const duplicateCount = data[i][1]; // Number of duplicates
    if (!subjectKeyword || !duplicateCount) continue; // Skip if data is missing

    // Search drafts by subject keyword
    const templateQuery = `subject:"${subjectKeyword}" in:drafts`; // Search query for drafts
    const threads = GmailApp.search(templateQuery);

    if (threads.length > 0) {
      const message = threads[0].getMessages()[0]; // Get the first message in the thread
      const subject = message.getSubject();
      const htmlBody = message.getBody(); // Get the HTML body
      const plainBody = message.getPlainBody(); // Get the plain text body
      const to = message.getTo(); // Recipients
      const cc = message.getCc(); // CC
      const bcc = message.getBcc(); // BCC

      const bodyToUse = htmlBody || plainBody;

      for (let j = 0; j < duplicateCount; j++) {
        if (htmlBody) {
          GmailApp.createDraft(to, subject, '', { htmlBody: bodyToUse, cc: cc, bcc: bcc });
        } else {
          GmailApp.createDraft(to, subject, bodyToUse, { cc: cc, bcc: bcc });
        }
      }
      Logger.log(`Draft duplicated: ${subject} × ${duplicateCount} times`);
    } else {
      Logger.log(`No drafts found matching the subject: "${subjectKeyword}"`);
    }
  }
}
STEP
Save the Script

After writing the script, name and save it.

(e.g., “Draft Duplication”)

STEP
Run the Script

Run the script to duplicate the draft emails.

If you’re running the script for the first time, you need to authorize it.

Therefore, press “Review Permissions.

Detailed Authorization Steps

Press “Advanced.”

Press “Go to Untitled project (Unsafe).”

After that, press “Allow.”

STEP
Draft Emails are Duplicated

If the draft includes recipients (including Cc and Bcc), they will be duplicated exactly as in the original draft.

Notes

Multiple Drafts with the Same Subject

If there are multiple drafts with the same subject, only the first draft found will be duplicated.

Gmail Limitations

Duplicating a large number of drafts may trigger Gmail’s API limits. (Be cautious if exceeding 50 drafts at a time.)

For more information on Gmail limitations, please refer to Gmail’s API limits documentation.

Conclusion

We’ve introduced a step-by-step method for efficiently duplicating Gmail drafts using Google Sheets and Google Apps Script.

Additionally, with Apps Script, you can dynamically modify parts of the email body and automate sending personalized emails to multiple recipients.

For detailed instructions on how to achieve this, please refer to the article below.

Our company offers support for improving work efficiency through the use of Google Apps Script.
If you need assistance with Google Apps Script customization or error resolution, please feel free to contact us.
We are fully committed to supporting your business improvements.

Contact us here

Let's share this post !

Comments

To comment

TOC