将Gmail数据(上次联系的日期)提取到Google工作表中

问题描述 投票:0回答:1

我正在尝试在Google电子表格中收集与一个特定电子邮件地址相关的最新活动的日期。

因此,理想情况下,我想输入电子邮件地址列表,并在下一列获取最新互动的日期(传入或传出电子邮件)

我一直在寻找附加组件,但目前还没有运气。

任何人都可以帮忙吗?

非常感谢,

杰里米

google-sheets gmail gmail-addons
1个回答
0
投票

解决方案

这是一段代码,它执行您尝试实现的目标,并附有解释其工作原理的注释:

function myFunction() {
  // Get the value in the cell A1 (which will have the email to check the latest interaction)
  var ss = SpreadsheetApp.getActive().getSheetByName('Sheet1').getRange('A1').getValue();
  
  // Search the date of the last message of the search from the email in cell A1 and log it
  var latestEmail = GmailApp.search('from:"'+ss+'"')[0].getLastMessageDate();
  Logger.log(latestEmail);
}

我希望这对您有所帮助。让我知道您是否还需要其他什么,或者您是否不了解。 :)

© www.soinside.com 2019 - 2024. All rights reserved.