( ゚д゚)ハッ! Advent Calendarのネタが付きかけている!!
というわけで、クソアプリ系のネタです。
Gmailに何通メールが届いたか知るのにいちいちクエリ書いて... っていうのも面倒なので、集計してメール送ってもらうようにしました。
function sumally()
{
var n = new Date();
var y = (function(){this.setDate(this.getDate()-1); return this}).call(new Date);
var today = n.getFullYear() + "-" + (n.getMonth() + 1) + "-" + n.getDate()
var yesterday = y.getFullYear() + "-" + (y.getMonth() + 1) + "-" + y.getDate()
var sentCount = 0, receivedCount = 0;
//Received count
var receivedSearchQuery = "before:"+today+" after:"+yesterday+" -is:sent";
var threads = GmailApp.search(receivedSearchQuery, 0, 500);
for(var i=0; i<threads.length; i++)
{
receivedCount = receivedCount + threads[i].getMessageCount();
}
GmailApp.sendEmail(getEmailAddress(), "summary: " + yesterday, receivedCount+" received");
Logger.log(yesterday +" : "+receivedCount+" received");
}
function getEmailAddress() {
return YOUR_EMAIL_ADDRESS;
}