在下面的代碼中,我能夠發送自動電子郵件,并且部分成功。我不確定如何獲取電子郵件中的超鏈接。
//對于此代碼,我可以將其發送到所有電子郵件但沒有超鏈接
function testnotif() {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Emails").activate();
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var lr = ss.getLastRow();
var templatetext = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Template").getRange(1, 1).getValue();
for (var i=2;i<=lr;i ){
var currentemail = ss.getRange(i, 1).getValue();
var currenttitle = ss.getRange(i, 3).getValue();
var currentname = ss.getRange(i, 2).getValue();
var sheetID = ss.getRange(i, 4).getValue();
var messagebody = templatetext.replace("{name}",currentname).replace("{title}",currenttitle).replace("{sheet}",sheetID);
var subjectline = "Reminder: " currenttitle ;
MailApp.sendEmail(currentemail,subjectline,messagebody);
}
}
//
//在此代碼中,我可以發送超鏈接,但無法將其發送到多個電子郵件地址
function testnotif(){
var ss = SpreadsheetApp.openById('1HVktteGM2wRXNuneZ1VVqtVg3G4WvkeFIcrLq4v-8M4');
var sheet = ss.getSheetByName("Emails");
var lr = ss.getLastRow();
var data = sheet.getRange(lr, 1).getValue();
MailApp.sendEmail({
to:data,
subject: "Monthly test",
htmlBody: "Hi Team,<br><br>" "This is a gentle reminder to start your test and complete it by 25th of this month. You can find your test Dashboard in this " "<a href=\"https://docs.google.com/spreadsheets/d/1dyjQO51zqBo6DRXB48r7azy_ktFa1LwpIJ55DflDHOA/edit#gid=0\">sheet.</a>" "<br><br>Let me know if you have any questions. " "<br><br>Thank you."
});
}
//
先感謝您
uj5u.com熱心網友回復:
只需添加ccor bcc,無論您是否希望其他收件人可見:
MailApp.sendEmail({
to:data,
cc: `[email protected], [email protected]`,
// or hide recipients:
// bcc: `[email protected], [email protected]`,
subject: "Monthly test",
htmlBody: "Hi Team,<br><br>" "This is a gentle reminder to start your test and complete it by 25th of this month. You can find your test Dashboard in this " "<a href=\"https://docs.google.com/spreadsheets/d/1dyjQO51zqBo6DRXB48r7azy_ktFa1LwpIJ55DflDHOA/edit#gid=0\">sheet.</a>" "<br><br>Let me know if you have any questions. " "<br><br>Thank you."
});
編輯:
如果您有一列電子郵件地址要放入ccorbcc欄位,則需要將它們轉換為逗號分隔的string:
const recipients = SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName(`Emails`)
.getRange(`A2:A`) // Adjust as needed.
.getValues()
.filter(Boolean) // Remove empty rows.
// If the primary recipient is in the last row:
//.slice(0, -1)
.flat()
.join(`, `) // Convert to comma-separated string.
// recipients = "[email protected], [email protected], ..."
MailApp.sendEmail({
to: data,
cc: recipients,
// or hide recipients:
// bcc: `[email protected], [email protected]`,
subject: "Monthly test",
htmlBody: "Hi Team,<br><br>" "This is a gentle reminder to start your test and complete it by 25th of this month. You can find your test Dashboard in this " "<a href=\"https://docs.google.com/spreadsheets/d/1dyjQO51zqBo6DRXB48r7azy_ktFa1LwpIJ55DflDHOA/edit#gid=0\">sheet.</a>" "<br><br>Let me know if you have any questions. " "<br><br>Thank you."
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/494440.html
上一篇:GoogleApps腳本或JavaScript-查找和替換結果比要求的高一排-如何將其上移一排以進行替換?
下一篇:這在谷歌作業區加載項中叫什么?
