我已经成功检索了电子邮件,并将其插入带有参考链接https://gist.github.com/takvol/0a0dd9b089314bc5463eaf6af83fa060的Google表格中。 因此,在填充工作表后,说出100行(A至H列),并在最后一列(I),如果条件达到H列的参考值,我想更新每行的状态(I列)并从不同的电子邮件中检索数据。 可能吗 ?如果可能的话,如何?
此致
发性
function extractData(data, startStr, endStr) {
var startIndex, endIndex, text = '';
startIndex = data.indexOf(startStr);
if (startIndex != -1) {
startIndex += startStr.length;
text = data.substring(startIndex);
if (endStr) {
endIndex = text.indexOf(endStr);
if (endIndex != -1) {
text = text.substring(0, endIndex);
} else {
text = '';
}
}
}
return text;
}
function retrieveWd() {
var start = 0;
var sheet, threads, labelName, label, emptype, worker, fullname, loc, dept, job, mgr, startdate, email, asset;
sheet = SpreadsheetApp.getActive().getSheetByName("allocations");
threads = GmailApp.search('in:inbox', start, 100);
for (var i = 0; i < threads.length; i++) {
if (threads[i].getFirstMessageSubject().search("New Hire - IT Onboarding") > -1) {
var message = threads[i].getMessages()[0];
var content = message.getPlainBody();
if (content) {
var emp = extractData(content, "Employee Type: ", "\n");
Logger.log(emp[0]);
if (emp != '') {
emptype = extractData(content, "Employee Type: ", "\n"),
worker = extractData(content, "Workday Employee ID: ", "\n"),
fullname = extractData(content, "Full Name: ", "\n"),
loc = extractData(content, "Location: ", "\n"),
dept = extractData(content, "Department/ Team: ", "\n"),
job = extractData(content, "Business Title: ", "\n"),
mgr = extractData(content, "Manager's Email: ", "\n"),
startdate = extractData(content, "Start Date: ", "\n"),
email = extractData(content, "Email address : ", "\n"),
asset = extractData(content, "Asset No : ", "\n");
sheet.appendRow(['', '', emptype, worker, fullname, '', loc, dept, job, mgr, startdate, '', email, asset]);
} else if (emp == '') {
worker = extractData(content, "Worker ID: ", "\n"),
fullname = extractData(content, "Full Name: ", "\n"),
loc = extractData(content, "Location: ", "\n"),
dept = extractData(content, "Department/Team: ", "\n"),
job = extractData(content, "Business Title: ", "\n"),
mgr = extractData(content, "Manager's Email: ", "\n"),
startdate = extractData(content, "Start Date: ", "\n"),
email = extractData(content, "Email address : ", "\n"),
asset = extractData(content, "Asset No : ", "\n");
sheet.appendRow(['', '', 'Temporary', worker, fullname, '', loc, dept, job, mgr, startdate, '', email, asset]);
}
Utilities.sleep(500);
}
}
}
}
我想更新从电子邮件中检索的列收据。