簡體   English   中英

腳本Google表單-郵件確認htmlBody

[英]Script google form - mail confirmation htmlBody

我使用此腳本在Google表單完成后發送帶有附件的郵件確認。 一切正常,但我想將hmtl用於郵件正文。

實際上,我使用“ var htmlBody”,但在郵件確認中未解釋html。

謝謝你的幫助 !

function onFormSubmit(e) {
  var timestamp = e.values[0];
  var email = e.values[2];

  var subject = "Votre demande";
  var htmlBody = "Madame, Monsieur, <br>Veuillez trouver ci-joint le(s) documents demandés. Nous sommes à votre entière disposition pour vous apporter de l'aide dans votre recherche de mode de garde. Vous retrouverez toutes nos coordonnées en pièce jointe. <br>Bien cordialement,";
  var file = DriveApp.getFileById("1KKDr2bIwi1k_nOi3DR-TlnLfDDHLwc7mdV8SL24db-k")
  var file2 = DriveApp.getFileById("1RCBty4E2MCuj1ZV3MGCmZxGFsA2bXUiVBwCxHGJJCU4")
  var pdfFile = file.getAs(MimeType.PDF);
  var pdfFile2 = file2.getAs(MimeType.PDF);
  if (e.values[1] == "La liste des assistants maternels") {
    MailApp.sendEmail(email, subject, htmlBody, {
      attachments: [pdfFile]
    });
  }
  if (e.values[1] == "Le dossier de pré-inscription en crèche") {
    MailApp.sendEmail(email, subject, htmlBody, {
      attachments: [pdfFile2]
    });
  }
  if (e.values[1] == "La liste des assistants maternels, Le dossier de pré-inscription en crèche") {
    MailApp.sendEmail(email, subject, htmlBody, {
      attachments: [pdfFile, pdfFile2]
    });
  }
}

我認為您可以通過移動htmlBody解決您的問題。 有兩種實現所需目標的模式。

模式1

MailApp.sendEmail(
  email,
  subject,
  "sample text", // If HTML can't be received, this is used.
  {
    htmlBody: htmlBody,
    attachments: [pdfFile]
  }
);

模式2

MailApp.sendEmail({
  to: email,
  subject: subject,
  body: "sample text", // If HTML can't be received, this is used.
  htmlBody: htmlBody,
  attachments: [pdfFile]
});

參考:

如果這對您的情況沒有幫助,對不起。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM