我有一个客户反馈表,并且开发了一个脚本来分配参考号并通过电子邮件将其发送给客户。 唯一的挑战是它是从我的个人邮箱发送的,我们需要对其进行调整以从我委托的邮箱发送它(但由于我们公司的IT管理所有委托的邮箱而没有所有权)。 我不能作为代理人身份登录,因为我是代理人而不是所有者。我尝试使用别名,但后来却无法提供所需的权限(因为我不是所有者)。
有什么想法吗?还是计算机说不 (我确信代码会更优雅,这是我的第一次,因此,也很高兴能收到有关使其更高效/更优雅的反馈)
function EmailCustomer() {
range = SpreadsheetApp.getActiveSheet().getLastRow();
var aliases = GmailApp.getAliases();//getting all my aliases (info_blx@hillspet.com)
var startRow = 2;//first row of data
var numRows = range;//last row of data
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var dataRange = sheet.getRange(startRow, 1, numRows, 2000)//get values for each row in range
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
var emailAddress = row[1]; // column B
var referencen = row[40]; // column AO
if (!referencen) {continue;}
var emailSent = row[41]; // column AP
if (emailSent != "EMAIL_SENT") { // Prevents sending duplicates
var why = row[3];
var subject = "Uw Hill's referentienummer voor " + row[2];
var alias= "preas"
var message = "Bedankt dat u met ons contact heeft opgenomen over: " + why + "." +"\nUw referentienummer voor correspondentie hierover is " + referencen + "."+"\nOns streven is om binnen 48 uur op uw verzoek/vraag te reageren. Heeft u na deze tijd nog niets van ons vernomen? Onze klantenservice is op werkdagen (08:30-17:00) telefonisch (076-5481888 NL/ 02-6467700 BE) of via info_blx@hillspet.com bereikbaar.";
MailApp.sendEmail(emailAddress, subject, message, {from: alias});//send email
sheet.getRange(startRow + i, 42).setValue("EMAIL_SENT"); // Make sure the cell is updated right away in case the script is interrupted
SpreadsheetApp.flush();
}
}
}