网页Javascript提交OutLook发送邮件
<
html
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
/>
<
title
>
网页Javascript提交OutLook发送邮件
</
title
>
</
head
>

<
script
language
="javascript"
>
...

function toOutLook()...{
var objFrm = document.frmEmail;
var objFrmOutLook = document.frmEmailOutLook;
var msg = "";
msg += "姓名: " + objFrm.name.value + " ";
msg += "电话: " + objFrm.phone.value + " ";
msg += "网址: " + objFrm.website.value + " ";
msg += "主题: " + objFrm.subject.value + " ";
msg += "内容: " + objFrm.message.value + " ";
objFrmOutLook.message.value = msg;
objFrmOutLook.action = "mailto:sundysea@hotmail.com?subject=" + objFrm.subject.value;
objFrmOutLook.submit();
}
</
script
>
<
body
>
<
form
name
="frmEmailOutLook"
action
=""
method
="post"
enctype
="text/plain"
>
<
input
type
="hidden"
name
="message"
value
=""
>
</
form
>

<
form
name
="frmEmail"
action
=""
method
="post"
>
姓名:
<
input
type
="text"
name
="name"
value
="a"
><
BR
>
电话:
<
input
type
="text"
name
="phone"
value
="b"
><
BR
>
网址:
<
input
type
="text"
name
="website"
value
="c"
><
BR
>
主题:
<
input
type
="text"
name
="subject"
value
="d"
><
BR
>
内容:
<
textarea
name
="message"
>
ee
ddd
</
textarea
><
BR
>
<
input
type
="button"
name
="send"
value
="send"
onClick
="toOutLook()"
>
</
form
>
</
body
>
</
html
>
<
html
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
/>
<
title
>
网页Javascript提交OutLook发送邮件
</
title
>
</
head
>

<
script
language
="javascript"
>
...

function toOutLook()...{
var objFrm = document.frmEmail;
var objFrmOutLook = document.frmEmailOutLook;
var msg = "";
msg += "姓名: " + objFrm.name.value + " ";
msg += "电话: " + objFrm.phone.value + " ";
msg += "网址: " + objFrm.website.value + " ";
msg += "主题: " + objFrm.subject.value + " ";
msg += "内容: " + objFrm.message.value + " ";
objFrmOutLook.message.value = msg;
objFrmOutLook.action = "mailto:sundysea@hotmail.com?subject=" + objFrm.subject.value;
objFrmOutLook.submit();
}
</
script
>
<
body
>
<
form
name
="frmEmailOutLook"
action
=""
method
="post"
enctype
="text/plain"
>
<
input
type
="hidden"
name
="message"
value
=""
>
</
form
>

<
form
name
="frmEmail"
action
=""
method
="post"
>
姓名:
<
input
type
="text"
name
="name"
value
="a"
><
BR
>
电话:
<
input
type
="text"
name
="phone"
value
="b"
><
BR
>
网址:
<
input
type
="text"
name
="website"
value
="c"
><
BR
>
主题:
<
input
type
="text"
name
="subject"
value
="d"
><
BR
>
内容:
<
textarea
name
="message"
>
ee
ddd
</
textarea
><
BR
>
<
input
type
="button"
name
="send"
value
="send"
onClick
="toOutLook()"
>
</
form
>
</
body
>
</
html
>
点击Send发送之后的内容为
----------------------------------------
收件人: sundysea@hotmail.com
主题: d
message=姓名: a
电话: b
网址: c
主题: d
内容: ee
ddd
----------------------------------------
注意的几个地方:
默认发送格式为表单名称=内容.
所以在上面我做了两个表单,先组合好内容,然后发送,这样就只有一个表单,而且内容前面有说明(表单的说明)
表单的属性设置,增加enctype="text/plain"(是以文本方式发送),或者 ENCTYPE="multipart/form-data"(是将文本打包成附件**.ATT的附件)
<form name="frmEmailOutLook" action="" method="post" enctype="text/plain">
发送表单action的格式
mailto:目的邮件地址?subject=邮件主题&Bcc=转送(不记得了)&cc=抄送

本文介绍了一种使用JavaScript从网页中收集表单数据并通过Outlook发送邮件的方法。通过创建两个表单并利用`mailto:`协议,可以将表单数据格式化为易于阅读的邮件内容。
1万+

被折叠的 条评论
为什么被折叠?



