google-sheets - 提取 gmail 数据(最后一次联系的日期)到谷歌表
问题描述
我试图在谷歌电子表格上收集与一个特定电子邮件地址相关的最新活动的日期。
所以理想情况下,我想输入一个电子邮件地址列表,并在下一列中显示最新交互的日期(传入或传出的电子邮件)
我一直在寻找一个附加组件,但现在没有运气。
任何人都可以帮忙吗?
非常感谢,
杰里米
解决方案
Solution
This can easily be achieved using Apps Script. In the Spreadsheet with your email addresses go to Tools->Script Editor and use the code below by running the script (Run->Run function -> myFunction).
This is the piece of code that performs what you were trying to achieve with comments explaining how it works:
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);
// Print the date on the cell to the right
SpreadsheetApp.getActive().getSheetByName('Sheet1').getRange('B1').setValue(latestEmail);
}
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
推荐阅读
- c++ - 如何在非 STL 图中找到最小元素?
- react-native - 将自定义图标导入 React Native 0.62
- julia - 为什么存在“Int”,而不存在“Float”?
- algorithm - 有向无环图的随机生成是否存在已证明的理论最低时间复杂度?
- python - 为什么 Python 会截断完美的浮点值?
- javascript - 如何从自定义表单将多个文件上传到 Magnolia CMS 资产应用程序
- html - 如何在css中更改图像的透明背景颜色?
- hellosign-api - HelloSign 模板 - 不显示我(发送时)
- amazon-web-services - 如何在从 ALB 目标组中删除的 EC2 实例上执行脚本?
- scala - 如何从scala案例类中的伴随应用方法调用构造函数?