Gmail 的应用程序脚本 - 搜索确切的主题

Ilj*_*lja 4 gmail google-apps-script

我每天都会收到多封自动电子邮件。一个主题是“每日报告”,一个主题是“每日报告详细信息”。这是我使用的脚本,但是一旦电子邮件开始不按时间顺序发送,我有时会发现错误的。

 var threads = GmailApp.search('Daily Report') //search gmail with the given query(partial name using * as a wildcard to find anything in the current subject name).
 var msgs = GmailApp.getMessagesForThreads(threads);
Run Code Online (Sandbox Code Playgroud)

有没有办法告诉搜索我想要主题为“每日报告”而不是“每日报告详细信息”的邮件?

谢谢

小智 5

就像提到的@Pierre-Marie Richard 和@Cooper 一样,您可以使用内置的 Gmail 搜索功能。以下是Gmail 搜索功能的列表,就像@Cooper 提到的那样,您最好使用以下功能:

var threads = GmailApp.search('subject:"Daily Report"-Details')
var msgs = GmailApp.getMessagesForThreads(threads);
Run Code Online (Sandbox Code Playgroud)

引号 ( "" ) 用作完全匹配,减号 (' - ') 用于排除单词。如果这仍然不起作用,请告诉我,我会进一步调查。

祝你好运 :)