Skip to content

Instantly share code, notes, and snippets.

@yuririn
Last active November 13, 2017 08:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuririn/d9109e6bae8ffff17435fa29f6cd29ed to your computer and use it in GitHub Desktop.
Save yuririn/d9109e6bae8ffff17435fa29f6cd29ed to your computer and use it in GitHub Desktop.
function autoReply(){
var title = "お問い合わせありがとうございます / カルチャーアカデミア";
var body
= "この度はお問い合わせありがとうございました。\n後ほど、担当者よりご連絡させていただきます。\n"
+ "------------------------------------------------------------\n";
var footer
= "------------------------------------------------------------\n\n"
+ "エムフィールド広島オフィス 担当:かみーゆ";
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getLastRow();
var cols = sheet.getLastColumn();
var rg = sheet.getDataRange();
for (var i = 1; i <= cols; i++ ) {
//セルの最初の行(項目名)を取得
var col_name = rg.getCell(1, i).getValue();
//最後の行に追加されたセルを取得
var col_value = rg.getCell(rows, i).getValue();
//名前をメール本文の最初に追加
if(col_name == 'お名前'){
body = col_value +"様\n" + body;
}
//メールアドレスを取得
if(col_name == 'メールアドレス'){
var mail = col_value;
}
}
body += footer;
//メール送信
GmailApp.sendEmail(mail, title, body);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment