Skip to content

Instantly share code, notes, and snippets.

@Kazuki-tam
Created March 8, 2020 10:24
Show Gist options
  • Save Kazuki-tam/af648488d2eb5b35b399051f2b480ceb to your computer and use it in GitHub Desktop.
Save Kazuki-tam/af648488d2eb5b35b399051f2b480ceb to your computer and use it in GitHub Desktop.
function sendForm(e){
// 件名
var subject = "問い合わせが送信されました!";
// 本文
var body = "以下のお問合せがありましたのでご確認ください。";
// メール送信先
var to = "sample@example.com";
var itemResponses = e.response.getItemResponses();
for (var i = 0; i < itemResponses.length; i++) {
var itemResponse = itemResponses[i];
var question = itemResponse.getItem().getTitle();
var answer = itemResponse.getResponse();
body += "\n\n【" + question + "】\n\n";
body += answer;
// 回答内容に応じた出しわけ
if (question==="お問い合わせ内容") {
if (answer==="Webサイト構築") {
to = "sample1@example.com";
subject = "Webサイト構築の問い合わせが送信されました!";
} else if (answer==="SEO改善") {
to = "sample2@example.com";
subject = "SEO改善の問い合わせが送信されました!";
} else if (answer==="SNS運用") {
to = "sample3@example.com";
subject = "SNS運用の問い合わせが送信されました!";
}
}
}
MailApp.sendEmail({to:to,subject:subject, body:body});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment