Skip to content

Commit

Permalink
Merge pull request #77 from ttsukagoshi/main
Browse files Browse the repository at this point in the history
Release v3.0.1
  • Loading branch information
ttsukagoshi authored Apr 14, 2021
2 parents 7db1987 + a2edb60 commit 6a918df
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 1 addition & 5 deletions src/_debug.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* global UP_KEY_CREATED_DRAFT_IDS, UP_KEY_PREV_CONFIG, UP_KEY_USER_CONFIG */
/* 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();
}
15 changes: 9 additions & 6 deletions src/mailMerge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -451,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(),
Expand All @@ -467,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);
Expand Down

0 comments on commit 6a918df

Please sign in to comment.