将电子邮件从HTML发送到JavaScript [英] Sending email from HTML to JavaScript

查看:116
本文介绍了将电子邮件从HTML发送到JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我得到了一个作业,我无法弄清楚如何根据字段发送电子邮件。



例如我有四个文本字段:title ,姓/名和电子邮件。

然后按一下确认按钮。按下按钮时,它将运行脚本。



我运行了脚本,但只有固定数据,这不是必需的。



提前致谢!



这是我的剧本:

 <   script  >  
function sendEmail()
/ *此脚本按确认将自动打开默认电子邮件软件,以便将电子邮件发送到主题Assignment4提供的地址
和来自输入字段的正文。
* /
{
window.open('mailto:test@example.com?subject = Assignment4& body = SUSHI-MASTER James Tam');
}
< / script >

解决方案

1。如上所述创建带有文本框的表单



2.

隐藏复制代码
< script >
function sendEmail()
/ *此脚本按确认将自动打开默认电子邮件软件,以便将电子邮件发送到主题Assignment4提供的地址
和来自输入字段的正文。
* /
{

window.open('mailto:'+ document.getElementById(txtMailToId)。value +'?subject ='+ document.getElementById(txtTitle )。value +'4& body ='+ document.getElementById(txtFirstName)。value ++ document.getElementById(txtLastName)。value);
}
< / script >


Hello I got an assignment and I can't figure out how to send email based on the fields.

So for example I have four text fields: title, first/last name and email.
Then a button "confirm". When the button is pressed it will run the script.

I got the script running but only with fixed data, which is not quite what is required.

Thanks in advance!

This is my script:

<script>
function sendEmail()
/* This script by pressing "Confirm" will automatically open a default email software to send email to the address
provided with subject "Assignment4" and body from the input fields.
*/
{
    window.open('mailto:test@example.com?subject=Assignment4&body=SUSHI-MASTER James Tam');
}
</script>

解决方案

1. Create a form with textboxes as you have mentioned

2.

Hide   Copy Code
<script>
function sendEmail()
/* This script by pressing "Confirm" will automatically open a default email software to send email to the address
provided with subject "Assignment4" and body from the input fields.
*/
{

window.open('mailto:'+document.getElementById ( " txtMailToId").value+'?subject='+document.getElementById ( " txtTitle").value+'4&body='+document.getElementById ( " txtFirstName").value+" " + document.getElementById ( " txtLastName").value);
}
</script>


这篇关于将电子邮件从HTML发送到JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆