正如物件中提到的那樣,我試圖找出解決我的錯誤的方法。出了點問題
GmailApp.sendEmail。
順便說一句,我絕對是 GAS 編碼的新手,如果您認為可以增強腳本,請隨意。
function emailAsPDF() {
SpreadsheetApp.flush();
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setActiveSheet(ss.getSheetByName("Recherche"));
var sheet = ss.getActiveSheet();
var gid = sheet.getSheetId();
var pdfOpts =
// export as pdf
'&size=0' // paper size letter / You can use A4 or legal
'&portrait=false' // orientation portal, use false for landscape
'&fitw=true' // fit to page width false, to get the actual size
'&sheetnames=false&printtitle=true' // hide optional headers and footers
'&pagenumbers=true&gridlines=false' // hide page numbers and gridlines
'&fzr=true' // do not repeat row headers (frozen rows) on each page
'&attachment=false'
gid;
// '&size=0&fzr=true&portrait=false&fitw=true&gridlines=false&printtitle=true&sheetnames=false&pagenumbers=true&attachment=false&gid=' gid;
var url = ss.getUrl().replace(/edit$/, '') 'export?format=pdf' pdfOpts
var options = {
headers: {
'Authorization': 'Bearer ' ScriptApp.getOAuthToken()
}
}
options = {muteHttpExceptions: true};
var blobresponse = UrlFetchApp.fetch(url, options);
var CandidateName = ss.getRangeByName("Nom.Candidat").getValue();
var blob=blobresponse.getBlob().setName(ss.getName() " - " CandidateName ".pdf" );
var emailAddress=Session.getActiveUser().getEmail();
var signature = Gmail.Users.Settings.SendAs.get("me", emailAddress).signature;
var mess = "Voulez-vous envoyer votre rapport à l'adresse : " emailAddress;
var ans= Browser.msgBox("Courriel", mess, Browser.Buttons.YES_NO);
if (ans===Browser.Buttons.NO){return;}
var mess="Votre rapport a été envoyé à l'adresse : " emailAddress;
//var ss=SpreadsheetApp.getActive();
var sheet = ss.getSheetByName("Recherche");
var data = ss.getSheetByName("Données");
const corps = data.getRange("A24:E27").getValues();
const htmlTemplate = HtmlService.createTemplateFromFile("HtmlSigTemplate");
htmlTemplate.corps = corps;
var emailSubject = "Vérifications pré-emploi complétées" " - " CandidateName;
const htmlForEmail = htmlTemplate.evaluate().getContent() "--" "<br>" signature;
console.log(htmlForEmail);
//var emailMessage="Bonjour," "\n\n" "J’ai le plaisir de vous informer que les vérifications sont complétées pour le candidat indiqué au tableau de résultats pré-emploi suivant:" "\n\n" "Bonne journée !" "<br>" signature;
var shts=ss.getSheets();
GmailApp.sendEmail(
emailAddress,
emailSubject,
corps,
{htmlBody: htmlForEmail},
{attachments:[blob]});
Browser.msgBox("Courriel", mess, Browser.Buttons.OK);
}
uj5u.com熱心網友回復:
嘗試這個:
GmailApp.sendEmail(emailAddress,emailSubject,corps,{htmlBody:htmlForEmail, attachments:[blob]});
我想你的支架}不合適
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/377819.html
標籤:谷歌应用程序脚本
