Last active
May 3, 2024 22:00
-
-
Save idoleat/13325246fdac897f6343dea9cd7118ee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let EMAIL = { | |
'recipient': '', | |
'subject': '作業繳交驗證碼', | |
'body': '請在作業提交表單填入以下驗證碼:\n' | |
} | |
function getSignature(str){ | |
// second argument is a RSA private key in pem format, which could e generated by $ openssl genrsa | |
let sig = Utilities.computeRsaSha256Signature(str, | |
"-----BEGIN PRIVATE KEY-----\nYOUR_KEY\n-----END PRIVATE KEY-----\n"); | |
console.log(Utilities.base64Encode(sig)); | |
return Utilities.base64Encode(sig) | |
} | |
function onSubmit(e){ | |
let reponses = e.response.getItemResponses(); | |
EMAIL.recipient = reponses[0].getResponse(); | |
EMAIL.body += getSignature(reponses[0].getResponse()); | |
MailApp.sendEmail(EMAIL.recipient, EMAIL.subject, EMAIL.body); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment