gpt4 book ai didi

javascript - Google Apps脚本的邮件服务应用程序中的动态邮件ID

转载 作者:行者123 更新时间:2023-12-03 03:24:12 25 4
gpt4 key购买 nike

我需要将带有默认消息的邮件发送到用户在 html 表单的电子邮件字段中指定的邮件 ID。我尝试了以下代码,但不起作用。这里需要 URL 队列之类的东西吗?

<form method="POST" action="https://script.google.com/macros/s/AKfycbwIzz6c_PL7D9ioCrzDRvTdmBj2nZR-2ekUZ9pjgHeG3b3Simg/exec">
<label for="mail">Enter your mailID:</label>
<input type="email" id="mail" required>
<input type="submit">
</form>

Google 脚本 API:

 function doPost(e){
var addr = JSON.stringify(e);
MailApp.sendEmail(addr,
"Recovery email for TracerSC",
"Your one time password ");

}

这是我收到的错误

Invalid email: {"parameter":{},"contextPath":"","contentLength":0,"queryString":"","parameters":{}} (line 5, file "Code", project "email")

以下具有默认邮件 ID 的代码对我来说效果很好

function doPost(){

MailApp.sendEmail("example@abc.com",
"Recovery email for TracerSC",
"Your one time password ");

}

最佳答案

您可以通过将 name 属性添加到输入标记来检索值。修改后的 HTML 如下。在此示例中,您可以使用值 example@abc.com使用e.parameter.addr .

修改后的 HTML:

<form method="POST" action="https://script.google.com/macros/s/AKfycbwIzz6c_PL7D9ioCrzDRvTdmBj2nZR-2ekUZ9pjgHeG3b3Simg/exec">
<label for="mail">Enter your mailID:</label>
<input type="email" id="mail" name="addr" required>
<input type="submit">
</form>

edoPost(e)

{
"parameter": {
"addr": "example@abc.com"
},
"contextPath": "",
"contentLength": 22,
"queryString": "",
"parameters": {
"addr": [
"example@abc.com"
]
},
"postData": {
"type": "application/x-www-form-urlencoded",
"length": 22,
"contents": "addr=example%40abc.com",
"name": "postData"
}
}

如果我误解了你的问题,我很抱歉。

关于javascript - Google Apps脚本的邮件服务应用程序中的动态邮件ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46423710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com