網(wǎng)頁Javascript提交OutLook發(fā)送郵件
更新時間:2012-01-20 | 發(fā)布人:本站 | 點擊率:439 次
注意的幾個地方:
默認(rèn)發(fā)送格式為表單名稱=內(nèi)容.
所以在上面我做了兩個表單,先組合好內(nèi)容,然后發(fā)送,這樣就只有一個表單,而且內(nèi)容前面有說明(表單的說明)
表單的屬性設(shè)置,增加enctype="text/plain"(是以文本方式發(fā)送),或者 ENCTYPE="multipart/form-data"(是將文本打包成附件**.ATT的附件)
<form name="frmEmailOutLook" action="" method="post" enctype="text/plain">
發(fā)送表單action的格式
mailto:目的郵件地址?subject=郵件主題&Bcc=轉(zhuǎn)送(不記得了)&cc=抄送
以下是引用片段:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>網(wǎng)頁Javascript提交OutLook發(fā)送郵件</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 += "網(wǎng)址: " + objFrm.website.value + " ";
msg += "主題: " + objFrm.subject.value + " ";
msg += "內(nèi)容: " + 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>
網(wǎng)址:<input type="text" name="website" value="c"><BR>
主題:<input type="text" name="subject" value="d"><BR>
內(nèi)容:<textarea name="message" >ee
ddd</textarea><BR>
<input type="button" name="send" value="send" onClick="toOutLook()">
</form>
</body>
</html>
點擊Send發(fā)送之后的內(nèi)容為
----------------------------------------
收件人: sundysea@hotmail.com
主題: d
message=姓名: a
電話: b
網(wǎng)址: c
主題: d
內(nèi)容: ee
ddd