有没有一种方法可以检查是否使用Apps脚本以gmail发送特定邮件?

时间:2020-07-09 11:49:39

标签: google-apps-script google-sheets gmail

我想从gmail发送文件夹中获取具有特定主题的特定邮件,我该如何实现?只是指导我在哪里看待或放些可能有用的代码片段,如果条件比较检索到的已发送邮件与subject_variable之间的关系,则只是基本内容。

我的逻辑算法:

var subject_variable = "specific subject"

[some code to retrieve specific sent mail with subject_variable]

if(retrieved sent mail subject == subject_variable) 
return 0; 

else execute other part of code I prepared already

1 个答案:

答案 0 :(得分:1)

您可以使用GmailApp.search

您可以在此处指定主题或标签等参数。

示例:

function myFunction() {
  var messages = GmailApp.search("in : sent subject : specific subject");
  Logger.log("There are " + messages.length + " messages in Sent matching with the specified query.");
}