From 17c6dbc68883d85cac7ec1ef41bb56e3e2e179cb Mon Sep 17 00:00:00 2001 From: ttsukagoshi Date: Fri, 12 Jun 2020 15:16:05 +0900 Subject: [PATCH] Modified prompt message to enter subject --- src/mailMerge.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mailMerge.js b/src/mailMerge.js index c427fe9..d788c46 100644 --- a/src/mailMerge.js +++ b/src/mailMerge.js @@ -84,7 +84,7 @@ function sendPersonalizedEmails_(draftMode = true, config = CONFIG) { throw new Error('Mail merge canceled.'); } // Get template from Gmail draft - let promptMessage = 'Enter the subject text of Gmail draft to use as template.'; + let promptMessage = 'Enter the subject of Gmail template draft.'; let promptResult = ui.prompt(promptMessage, ui.ButtonSet.OK_CANCEL); let [selectedButton, subjectText] = [promptResult.getSelectedButton(), promptResult.getResponseText()]; if (selectedButton !== ui.Button.OK) { @@ -97,6 +97,10 @@ function sendPersonalizedEmails_(draftMode = true, config = CONFIG) { if (draftMessage.length > 1) { throw new Error('There are 2 or more Gmail drafts with the subject you entered. Enter a unique subject text.'); } + // Throw error if no draft template is found + if (draftMessage.lenth == 0 ){ + throw new Error('No template Gmail draft with matching subject found.'); + } // Store template into an object let template = { 'subject': subjectText,