道歉标题不确定该怎么称呼。
基本上,我在工作表中有一个脚本,该脚本可以从我的gmail电子邮件中提取信息,并将数据放入电子表格的标签中,效果很好。我遇到的问题是如何向每行添加另一条数据,该数据是对当天行数的计数。例如
[数字],[日期],[等]
1,12/07/2018,数据在这里
2,12/07/2018,数据在这里
3,12/07/2018,数据在这里
1,13/07/2018,数据在这里
1,14/07/2018,数据在这里
等
我打算每天晚上使用行索引并删除数据,但是我有一个IFTTT Applet,它在创建新行时运行,但是如果它过去已经处理过该行,则不会注册。< / p>
我的代码在这里,任何帮助将不胜感激
function parseEmailMessages() {
var sheet = SpreadsheetApp.getActiveSheet();
var label = GmailApp.getUserLabelByName("divido/accepted-new");
var threads = label.getThreads();
for (var i = 0; i < threads.length; i++) {
// Get the first email message of a threads
var tmp,tmpfc,
message = threads[i].getMessages()[0],
subject = message.getSubject(),
content = message.getPlainBody(),
edate = message.getDate(),
rep = " ";
// Get the plain text body of the email message
// You may also use getRawContent() for parsing HTML
// Implement Parsing rules using regular expressions
if (content) {
/*tmp = content.match(/Email Address:\s*([A-Za-z0-9@.]+)/);
var email = (tmp && tmp[1]) ? tmp[1].trim() : 'No email';*/
tmp = content.match(/Credit Amount: £\s*([A-Za-z0-9\s]+)(\r?\n)/);
var price = (tmp && tmp[1]) ? tmp[1] : 'No price';
tmp = content.match(/accepted \b\s*([A-Z]\w+\s*(([A-Z]\w+)))/);
var name = (tmp && tmp[1]) ? tmp[1] : 'No name';
tmp = content.match(/that \b\s*([A-Z]\w+)/);
var type = (tmp && tmp[1]) ? tmp[1] : 'No type';
} // End if
// Change name of payment type
if (type == "Shawbrook") {type = "Finance";}
else if (type == "Stripe") {type = "Card";}
else if (type == "Omni") {type = "Finance";}
// End Change name of payment type
// only run if price is over 1500
if (price > 1500) {
sheet.appendRow([ edate, content, name, price, type, i ]);
}
//END run if price is over 1500
//remove label from processed emails
threads[i].removeLabel(label);
//End remove label from processed emails
} // End for loop
}