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

Đang mở Phù hợp với người mới
#666 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu với getGmailTemplateFromDrafts_() trong solutions/automations/mail-merge/Code.js và theo dõi cách sendEmails() xử lý thư nháp đã chọn. Thêm hoặc tìm các bài kiểm thử sử dụng test double cho Gmail và Sheets; xác minh rằng hai thư nháp khớp nhau dẫn đến không có lời gọi gửi nào và một kết quả khớp vẫn được gửi bình thường. Hoàn tất khi có nhiều kết quả khớp thì quá trình dừng trước khi gửi và hiển thị thông báo yêu cầu một tiêu đề duy nhất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
5.3k
Fork
2k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googleworkspace/apps-script-samples

Tất cả issue của googleworkspace/apps-script-samples

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.