From 483ededdad0a08e51060a84d15206fa081ca3f9a Mon Sep 17 00:00:00 2001 From: ttsukagoshi <55706659+ttsukagoshi@users.noreply.github.com> Date: Fri, 26 Mar 2021 12:51:25 +0900 Subject: [PATCH 1/6] Move CODE_OF_CONDUCT.md to .github --- CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md From 282cec93457aab4141773f17ce0479849a61a133 Mon Sep 17 00:00:00 2001 From: ttsukagoshi <55706659+ttsukagoshi@users.noreply.github.com> Date: Fri, 26 Mar 2021 13:03:31 +0900 Subject: [PATCH 2/6] Modify resetUserProperties to delete all properties --- src/_debug.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/_debug.js b/src/_debug.js index fa7e10c..cb55e81 100644 --- a/src/_debug.js +++ b/src/_debug.js @@ -2,8 +2,5 @@ /* exported resetUserProperties */ function resetUserProperties() { - PropertiesService.getUserProperties() - .deleteProperty(UP_KEY_USER_CONFIG) - .deleteProperty(UP_KEY_PREV_CONFIG) - .deleteProperty(UP_KEY_CREATED_DRAFT_IDS); + PropertiesService.getUserProperties().deleteAllProperties(); } \ No newline at end of file From facffa3d702fad37d794f7eab394a62f9c0277cb Mon Sep 17 00:00:00 2001 From: ttsukagoshi <55706659+ttsukagoshi@users.noreply.github.com> Date: Fri, 26 Mar 2021 13:08:29 +0900 Subject: [PATCH 3/6] Address eslint error --- src/_debug.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/_debug.js b/src/_debug.js index cb55e81..534f847 100644 --- a/src/_debug.js +++ b/src/_debug.js @@ -1,4 +1,3 @@ -/* global UP_KEY_CREATED_DRAFT_IDS, UP_KEY_PREV_CONFIG, UP_KEY_USER_CONFIG */ /* exported resetUserProperties */ function resetUserProperties() { From f782ecee8898de8845f1c299d0f351a3e6597ea6 Mon Sep 17 00:00:00 2001 From: ttsukagoshi <55706659+ttsukagoshi@users.noreply.github.com> Date: Fri, 9 Apr 2021 03:10:18 +0900 Subject: [PATCH 4/6] Resolve #66 replace getDraft(draftId).send() with getDrafts().forEach() to filter through all existing drafts --- src/mailMerge.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mailMerge.js b/src/mailMerge.js index 5d702e3..acac419 100644 --- a/src/mailMerge.js +++ b/src/mailMerge.js @@ -312,9 +312,11 @@ function sendDrafts(event) { throw new Error(localizedMessage.messageList.errorNoDraftToSend); } // Send emails - createdDraftIds.forEach(draftId => { - GmailApp.getDraft(draftId).send(); - messageCount += 1; + GmailApp.getDrafts().forEach(draft => { + if (createdDraftIds.includes(draft.getId())) { + draft.send(); + messageCount += 1; + } }); // Empty createdDraftIds createdDraftIds = []; From a8afa9a92f51d4cd9576b6d3825345b784cf49f0 Mon Sep 17 00:00:00 2001 From: ttsukagoshi <55706659+ttsukagoshi@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:28:00 +0900 Subject: [PATCH 5/6] Resolve #73 If To, CC, and BCC recipients in the template start with a comma, that comma will be removed --- src/mailMerge.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mailMerge.js b/src/mailMerge.js index acac419..99d3c2e 100644 --- a/src/mailMerge.js +++ b/src/mailMerge.js @@ -453,9 +453,7 @@ function mailMerge(draftMode = true, config = DEFAULT_CONFIG, prevProperties = { throw new Error(localizedMessage.messageList.errorNoMatchingTemplateDraft); } // Store template into an object - let messageTo = draftMessages[0].getTo(); - let messageCc = draftMessages[0].getCc(); - let messageBcc = draftMessages[0].getBcc(); + let [messageTo, messageCc, messageBcc] = [draftMessages[0].getTo(), draftMessages[0].getCc(), draftMessages[0].getBcc()]; let template = { 'subject': config.TEMPLATE_SUBJECT, 'plainBody': draftMessages[0].getPlainBody(), @@ -469,6 +467,9 @@ function mailMerge(draftMode = true, config = DEFAULT_CONFIG, prevProperties = { 'labels': draftMessages[0].getThread().getLabels(), 'replyTo': (config.ENABLE_REPLY_TO ? config.REPLY_TO : '') }; + template.to = (template.to.slice(0, 1) === ',' ? template.to.slice(1) : template.to); + template.cc = (template.cc.slice(0, 1) === ',' ? template.cc.slice(1) : template.cc); + template.bcc = (template.bcc.slice(0, 1) === ',' ? template.bcc.slice(1) : template.bcc); debugInfo.processTime.push(`Retrieved template draft data at ${(new Date()).getTime() - debugInfo.start} (millisec from start)`); // Check template format; plain or HTML text. let isPlainText = (template.plainBody === template.htmlBody); From 231a34f8ed7917b72d6c746d999262e2bcfe101f Mon Sep 17 00:00:00 2001 From: ttsukagoshi <55706659+ttsukagoshi@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:48:55 +0900 Subject: [PATCH 6/6] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a671a3..723194e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Similar to [the mail merge feature available in Microsoft Word](https://support. Details of the add-on is described in the [app's web page](https://www.scriptable-assets.page/add-ons/group-merge/). ## Terms and Conditions -You must agree to the [Terms and Conditions](https://www.scriptable-assets.page/terms-and-conditions/)(TaC) to use this add-on. The [disclosure on privacy and OAuth scopes](https://www.scriptable-assets.page/add-ons/group-merge/#disclosure-on-privacy-and-oauth-scopes) constitutes part of this TaC. +You must agree to the [Terms and Conditions](https://www.scriptable-assets.page/terms-and-conditions/) (TaC) to use this add-on. The [disclosure on privacy and OAuth scopes](https://www.scriptable-assets.page/add-ons/group-merge/#disclosure-on-privacy-and-oauth-scopes) constitutes part of this TaC. ## Attributes The original icon of this add-on was made by [Freepik](https://www.freepik.com) from [www.flaticon.com](https://www.flaticon.com/) and its colors are modified to fit the theme color of the app.