Skip to content

Commit

Permalink
Merge pull request #17 from ttsukagoshi/Update-README-for-Fixed-Line-…
Browse files Browse the repository at this point in the history
…Break

Update readme for fixed line break
  • Loading branch information
ttsukagoshi authored May 9, 2020
2 parents bf32442 + 78bdc41 commit 8f798d6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Edit your spreadsheet in any way you want to. If you want to change the sheet na
- The default value for the field (column) name of recipient email address is set to `Email`; change the value of `RECIPIENT_COL_NAME` in sheet `Config` to suit your needs
- Changing sheet name of `Config` is not recommended unless you are familiar with Google Apps Script and can edit the relevant section of the script.
- The lower-case letter `i` is reserved as part of the nested merge function, as described below, and cannot be used for a column name.
- Line breaks within a spreadsheet cell will be reflected in the plain text version of the merged mail, but not in the HTML version.

### 3. Create a template draft on Gmail
Create a Gmail draft to serve as the template. By default, the merge fields are specified by double curly brackets, i.e., `Dear {{Name}},... `. The field names should correspond with the column names of the spreadsheet (case-sensitive). If HTML mail is enabled, text styles of the draft template will be reflected on the personalized emails.
Expand Down
12 changes: 12 additions & 0 deletions src/mailMerge.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ function sendPersonalizedEmails_(draftMode = true, config = CONFIG) {
}
}

/**
* Process each element of an array with String.prototype.replace()
* @param {array} array Array containing values to replace.
* @param {string|RegExp} searchValue A RegExp object or literal, or string to be replaced by replaceValue
* @param {string} replaceValue String to replace the searchValue.
* @return {array} Array whose element(s) are replaced.
*/
function arrReplace_(array, searchValue, replaceValue) {
let replacedArray = array.map(value => value.replace(searchValue, replaceValue));
return replacedArray;
}

/**
* Returns an object of configurations from spreadsheet.
* @param {string} configSheetName Name of sheet with configurations. Defaults to 'Config'.
Expand Down

0 comments on commit 8f798d6

Please sign in to comment.