Mail merge sample silently picks the first draft when several drafts share the subject

未关闭 适合新手
#666 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
javascript
领域
backend

调研方向

从 solutions/automations/mail-merge/Code.js 中的 getGmailTemplateFromDrafts_() 开始,追踪 sendEmails() 如何处理选中的草稿。添加或查找使用 Gmail 和 Sheets 测试替身的测试;验证两个匹配的草稿会导致发送调用次数为零,而只有一个匹配项时仍会正常发送。完成标准:存在多个匹配项时,在发送前停止,并显示要求使用唯一主题的消息。

由索引模型根据 Issue 内容生成。

描述

getGmailTemplateFromDrafts_() in solutions/automations/mail-merge/Code.js selects the template with:

const draft = drafts.filter(subjectFilter_(subject_line))[0];

If the sender has two drafts with the same subject, for example an internal and a customer version of "Monthly update", the script uses whichever Gmail returns first, with its body and attachments, for every row in the sheet. Nothing tells the sender a choice was made.

We ran sendEmails() with Gmail and Sheets replaced by test doubles, using two drafts with the same subject and different attachments. Reversing the draft order changed which body and attachment went to every recipient. No real email was sent.

Proposed change: count the matching drafts and stop before sending if there is more than one, with a message asking the sender to make the subject unique. A test would check that two matches lead to zero send calls and one match sends normally.

Happy to send a pull request if this approach works for you.

— Emails.help

主要语言
JavaScript
星标
5.3k
派生
2k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleworkspace/apps-script-samples 的其他 Issue

查看 googleworkspace/apps-script-samples 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。