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 摘要。