본문 바로가기

WEB/Google App Script

Apps Scripts 구글 폼 등록 > 스프레드시트 등록 > 메일로 내용 받기



Apps Scripts 구글 폼 등록 > 스프레드시트 등록 > 메일로 내용 받기

참조 : 공식 문서 링크 
https://developers.google.com/apps-script/reference/mail/mail-app#sendemailmessage

 

Class MailApp  |  Apps Script  |  Google Developers

Send feedback Class MailApp MailApp Sends email. This service allows users to send emails with complete control over the content of the email. Unlike GmailApp, MailApp's sole purpose is sending email. MailApp cannot access a user's Gmail inbox. Changes to

developers.google.com

 

1. 편집기에서 코드를 편집한다.
구글 앱스크립트 편집기 화면
function onFormSubmit(e) {
    MailApp.sendEmail({
        to: "email@googleasdas.com",
        subject: e.values[1] + ' - 요청이 등록 되었습니다.',
        htmlBody: '<br>' + e.values[0] + ' 분에 ' + e.values[1] + ' <br>  요청이 등록되었습니다. 확인해주세요.' + '<br><br>' +
            '=========================================' + '<br>' +
            '채널이름 :  ' + e.values[1] + '<br>' +
            '검색용아이디 :  ' + e.values[2] + '<br>' +
            '소개문구 :  ' + e.values[3] + '<br>' +
            '출고방식 : ' + e.values[4] + '<br>' +
            '출고자명 : ' + e.values[5] + '<br>' +
            '=========================================' + '<br><br>' +
            '<a href="https://google.com">링크1</a> <br><br>' +
            '<a href="https://google.com">링크2</a>'
    });

}

1. 코드중 e.values[0] 는 구글 스프레트시트 열 순서 이다

 

2. 트리거를 등록한다.

1. 트리거 추가를 클릭하면 팝업창이 열린다.
2. 위 편집기에서 입력한 함수명이다.
3. 이 예제는 구글 폼 제출시 스프레드시트로 양식 제출시로 하였다.
3.1 데이터는 구글 폼을 등록해야하지만 스크립트는 실질적으로 스프레드시트에 등록됨으로 이벤트를 발생시킨다.
4. 저장한다.
반응형