Chunking of entire recipients+cc+bcc to avoid exceeding the 10 (recipient+cc+bcc) limit

When implementing new functionalities to send emails, we have to be careful about the NetSuite limitation. A maximum of 10 recipients (recipient + cc + bcc) is only allowed.

If we are only chunking the recipients, the cc and bcc will receive the same email more than once.

So for tackling this scenario, we have to chunk the entire recipients, ccs and bcc to avoid users getting duplicate emails.

/**
             * @description Checks conditions on whether to split or not split the set of                         emails to chunks
             * @param {Array} recipientArr | Recipient Array
             * @param {Array} ccArr | CC Array
             * @param {Array} bccArr | BCC Array
             * @returns {Array>} outputArr
             */
            let classifyEmails = (recipientArr, ccArr, bccArr) => {
                let outputArr = [];
                if ((Number(recipientArr.length) + Number(ccArr.length) + Number(bccArr.length)) > Number(EMAIL_THRESHOLD)) {
                    let possibleRecipientsLengthPerEmail = Number(EMAIL_THRESHOLD) - (Number(ccArr.length) + Number(bccArr.length));
                    outputArr = splitToGroups(recipientArr, possibleRecipientsLengthPerEmail);
                } else {
                    outputArr.push(recipientArr);
                }
                return outputArr;
            };

Leave a comment

Your email address will not be published. Required fields are marked *