怎样通过HTM页面直接提交到Email的表单
来源:互联网 发布:女生学软件测试好吗 编辑:程序博客网 时间:2024/06/06 02:45
怎样通过HTM页面直接提交到Email的表单
解决思路:
关键点是设置表单的action属性为”mailto:”+email地址。
(方法一) 具体步骤:
1.设置表单的action属性为接收邮件的email地址,并设置表单的MIME编码。 <form action="mailto:yourname@domain.com" enctype="text/plain">
</form>
2.设置邮件主题和正文的输入框
主题:<input name="subject" type="text"><br>
正文:<textarea name="body"></textarea><br>
<input name="subject" type="text">
3.设置抄送和密码地址输入框
抄送:<input name="cc" type="text"><br>
密送:<input name="bcc" type="text"><br>
4.完整代码
<form action="mailto:yourname@domain.com" enctype="text/plain">
主题:<input name="subject" type="text"><br>
抄送:<input name="cc" type="text"><br>
密送:<input name="bcc" type="text"><br>
正文:<textarea name="body"></textarea><br>
<input type="submit">
</form>
注意:
l 表单的action值的格式必须为"mailto:目标Email地址",这个跟做Email链接时类似。
l enctype(MIME编码)必须设置为"text/plain"(文本),否则收到的邮件是乱码。
l 表单的method属性不能设置为post,必须为get(默认不设置时为get),否则邮件的格式跟用户输入的不符合。
(方法二) 具体步骤:
<a href="mailto:youname@domain.com?subject=title&cc=name1@domain.com,name2@domain.com&bcc=bccname@domain.com&body=hello world!">mailto</a>
案例:
HTML代码:
<form name="form" method="post" action="mailto:service@kashuo.com" enctype="text/plain">
<table cellpadding="0" cellspacing="0">
<tr>
<th>姓名</th>
<td><input type="text" name="name" class="popup-btn"></td>
</tr>
<tr>
<th>联系电话</th>
<td><input type="text" name="iphone" class="popup-btn"></td>
</tr>
<tr>
<td></td>
<td><input name="close" type="bottn" onclick="getMailtoUrl()" class="popup-btn popup-btn1" value="提交申请">
</td>
</tr>
</table>
</form>
JS代码:
<script type="text/javascript">
function getMailtoUrl() {
var args = [];
if (typeof subject !== 'undefined') {
args.push('subject=' + encodeURIComponent('主题内容'));
}
var name = $("input[name='name']").val();
var iphone = $("input[name='iphone']").val();
var body = name +"\n"+iphone
if (typeof body !== 'undefined') {
args.push('body=' + encodeURIComponent(body))
}
var url = 'mailto:' + encodeURIComponent('service@kashuo.com');
if (args.length > 0) {
url += '?' + args.join('&');
}
console.log(url);
window.location = url;
return url;
}
</script>
怎样通过HTM页面直接提交到Email的表单
解决思路:
关键点是设置表单的action属性为”mailto:”+email地址。
(方法一) 具体步骤:
1.设置表单的action属性为接收邮件的email地址,并设置表单的MIME编码。 <form action="mailto:yourname@domain.com" enctype="text/plain">
</form>
2.设置邮件主题和正文的输入框
主题:<input name="subject" type="text"><br>
正文:<textarea name="body"></textarea><br>
<input name="subject" type="text">
3.设置抄送和密码地址输入框
抄送:<input name="cc" type="text"><br>
密送:<input name="bcc" type="text"><br>
4.完整代码
<form action="mailto:yourname@domain.com" enctype="text/plain">
主题:<input name="subject" type="text"><br>
抄送:<input name="cc" type="text"><br>
密送:<input name="bcc" type="text"><br>
正文:<textarea name="body"></textarea><br>
<input type="submit">
</form>
注意:
l 表单的action值的格式必须为"mailto:目标Email地址",这个跟做Email链接时类似。
l enctype(MIME编码)必须设置为"text/plain"(文本),否则收到的邮件是乱码。
l 表单的method属性不能设置为post,必须为get(默认不设置时为get),否则邮件的格式跟用户输入的不符合。
(方法二) 具体步骤:
<a href="mailto:youname@domain.com?subject=title&cc=name1@domain.com,name2@domain.com&bcc=bccname@domain.com&body=hello world!">mailto</a>
案例:
HTML代码:
<form name="form" method="post" action="mailto:service@kashuo.com" enctype="text/plain">
<table cellpadding="0" cellspacing="0">
<tr>
<th>姓名</th>
<td><input type="text" name="name" class="popup-btn"></td>
</tr>
<tr>
<th>联系电话</th>
<td><input type="text" name="iphone" class="popup-btn"></td>
</tr>
<tr>
<td></td>
<td><input name="close" type="bottn" onclick="getMailtoUrl()" class="popup-btn popup-btn1" value="提交申请">
</td>
</tr>
</table>
</form>
JS代码:
<script type="text/javascript">
function getMailtoUrl() {
var args = [];
if (typeof subject !== 'undefined') {
args.push('subject=' + encodeURIComponent('主题内容'));
}
var name = $("input[name='name']").val();
var iphone = $("input[name='iphone']").val();
var body = name +"\n"+iphone
if (typeof body !== 'undefined') {
args.push('body=' + encodeURIComponent(body))
}
var url = 'mailto:' + encodeURIComponent('service@kashuo.com');
if (args.length > 0) {
url += '?' + args.join('&');
}
console.log(url);
window.location = url;
return url;
}
</script>
阅读全文
0 0
- 怎样通过HTM页面直接提交到Email的表单
- 同一表单提交到不同的页面
- 通过不同的按纽把表单提交到不同页面
- 怎样提交表单但是不刷新页面
- 一个简单的表单提交页面,通过js进行验证
- 表单提交eMail
- 同一表单不同按钮提交到不同的页面
- 将一个表单提交到不同页面的方法
- 提交表单到不同字符集页面的方法
- 一个表单同时提交到两个不同的页面
- jsp页面中form表单提交到数据库的方法
- 提交表单数据到新打开的页面中
- 一个表单两个submit提交到不同的页面
- C#通过WebClient提交页面表单
- JSP通过表单提交到后台乱码
- showModalDialog窗口提交表单到本页面
- 提交表单到不同页面方式
- 页面表单提交的原理
- @SuppressWarning
- STM32 通用定时器的输出PWM功能 学习笔记
- 近期书单
- 大数运算
- 分享一项基于Android、iOS平台的移动端身份证识别技术
- 怎样通过HTM页面直接提交到Email的表单
- Java泛型详解
- struts 校验
- EhCache缓存在集群环境中同步问题
- python2.7下安装pyinstaller
- 三星g9298颜值最高的 价位还亲民的精仿顶级g9298
- 看项目代码的小技巧
- ajaxfileupload.js 在IE上传文件相关问题
- asp.net实现页面局部自动刷新