用于计算昨天收到的具有特定标签的电子邮件数量的 Google Apps 脚本,然后将 # 每天保存到电子表格 [英] Google Apps Script to count number of emails received yesterday, that has certain label, then save # daily to spreadsheet

查看:11
本文介绍了用于计算昨天收到的具有特定标签的电子邮件数量的 Google Apps 脚本,然后将 # 每天保存到电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上是标题所说的,但我想:

Basically what the title says, but I want to:

1) 自动统计收到到我的 gmail 帐户的电子邮件数量,上面有特定的标签

1) Automatically count the number of emails received to my gmail account, that has a certain label on it

2) 每天计数一次,即使是零

2) Count once everyday, even if zero

3) 每天向 Google 电子表格报告

3) And report daily to a Google Spreasheet

4) 所以我可以制作这样的月度报告:

4) So I can make a monthly report like such:

日期/#
日期/#
日期/#
.
.
.
10 月总计/#
平均每天/#

Date / #
Date / #
Date / #
.
.
.
Total for October / #
Average per day / #

我确信这是使用 Google Script 为脚本专家提供的小菜一碟,但我不知道.请教我!

I'm sure this is piece of cake using Google Script for script gurus, but I have no clue. Please teach me!

推荐答案

打开一个新的无标题电子表格并转到工具 -> 打开脚本编辑器并粘贴下面给出的代码.

Open a new Untitled spreadsheet and go to Tools -> open Script editor and paste the code given below.

function CountEmail() 
{
var label = GmailApp.getUserLabelByName("LabelName");
var labelname = label.getName();
var mails = label.getThreads();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
var date = new Date();
sheet.appendRow([labelname,date,mails.length]);
}

要每天运行脚本,您需要在应用脚本中设置项目触发器.为此,请按照以下步骤操作:

To run the script daily you will need to set a project trigger in the app script.For that follow the steps given below:

资源 -> 当前项目的触发器 -> 添加触发器 -> 时间驱动 -> 小时计时器 -> 选择您希望脚本运行的时间.

Resources -> Current Project's Trigger -> Add trigger -> Time driven -> Hour timer -> select the time when you want the script to run.

只需使用 Sum() 函数,即可在电子表格本身中计算电子邮件总数和平均电子邮件/天.

The total number of emails and the average emails/day can be calculated in the spreadsheet itself by just using the Sum() function.

这篇关于用于计算昨天收到的具有特定标签的电子邮件数量的 Google Apps 脚本,然后将 # 每天保存到电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆