用于发送电子邮件的 Google App Script IF 语句
只是想就我在 Google App Script 中的编码寻求一些帮助。
目标:一旦满足第 3 个条件(第 2 个条件位于同一列),我将尝试发送电子邮件。一旦脚本已经向该特定控制号码发送了电子邮件,脚本就不应再次向该交易发送电子邮件。但是,即使脚本已经发送到该事务,它仍然会发送电子邮件。我找不到问题出在哪里或者是否不满足我设定的条件。
列提交状态有“最终、取消、草稿” 列 processBy 有(仅限“ADMIN”)
if (submissionStatus !== "Draft" && processBy !== "") { // Prevents sending duplicates
var subject = "Cash_Advance ";
MailApp.sendEmail(currentEmail, subjectline, messageBody);
sheet.getRange(startRow + i, 38).setValue(EMAIL_SENT +" "+ Date()); // column AL
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
} //close if statement
if (submissionStatus !== "Cancelled" && processBy !== "") { // Prevents sending duplicates
var subject = "Cash_Advance ";
MailApp.sendEmail(currentEmail, subjectline, messageBody);
sheet.getRange(startRow + i, 38).setValue(EMAIL_SENT +" "+ Date()); // column AL
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
} //close if statement
Just want to ask some help regarding with my coding in Google App Script.
Objective: Am trying to send emails once I satisfy the 3 condition (the 2 condition is in the same column). And once the script already sent an email to that specific control number the script shouldn't send again to that transaction. However it still sending emails even if the script already sent to that transaction. I can't find where the problem is or if am not satisfying the condition I set.
Column SubmissionStatus have "Final, Cancelled, Draft"
Column processBy have ("ADMIN" only)
if (submissionStatus !== "Draft" && processBy !== "") { // Prevents sending duplicates
var subject = "Cash_Advance ";
MailApp.sendEmail(currentEmail, subjectline, messageBody);
sheet.getRange(startRow + i, 38).setValue(EMAIL_SENT +" "+ Date()); // column AL
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
} //close if statement
if (submissionStatus !== "Cancelled" && processBy !== "") { // Prevents sending duplicates
var subject = "Cash_Advance ";
MailApp.sendEmail(currentEmail, subjectline, messageBody);
sheet.getRange(startRow + i, 38).setValue(EMAIL_SENT +" "+ Date()); // column AL
// Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
} //close if statement
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以简单地将这两个 if 语句合并为一个,也许这就是它多次发送电子邮件的原因。
通过使用
submissionStatus === "Final"
在您最新编辑的上下文中:-
修改:
You can simply merge those two if statement into one, maybe that's why it is sending email more than once.
By using
submissionStatus === "Final"
In context of your latest edit:-
Modification: