Skip to content

Leaving cc field blank in metadata sheet but populating in merge sheet causes invalid email error #13

@benkloester

Description

@benkloester

If I do not populate the (per-merge) CC field in the Metadata sheet, but do use (per-email) CC in my merge sheet, then I will end up with a CC value something like undefined, <some.email.tocc@foo.bar> and when I call MailApp.sendEmail it will throw an invalid email error.

The problem appears to be on line 211:
const cachedCC = msgOptionsHash['cc']; - this is undefined in the case that CC in the metadata sheet wasn't populated. msgOptionsHas will only have a cc attribute at all if it is set, on line 154:if (cc != "") { msgOptionsHash['cc'] = cc; }, if the CC field is populated in the metadata sheet.

So when that undefined cc value gets cached at 211 it gets cached as undefined, and restored as such at 238, then the per-email cc gets appended to that undefined.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions