发邮件的asp(CDONTS.NewMail)

时间:2021-05-25

formmail.htm
复制代码 代码如下:
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<title>提交表单发送邮件</title>
</head>

<body>
<tablewidth="97%"border="1"cellspacing="5"cellpadding="1"align="center"bgcolor="#EEFFF4"height="630">
<tr>
<tdheight="440">
<formaction="sendMail.asp"target="_blank"method=post>
<inputname="mailTo"type=hiddenvalue="dayechg@163.com">
<inputname="title"type="hidden"id="title"value="网上预定">
<tableborder=0cellpadding=9cellspacing=0
width="100%">
<tbody>
<tr>
<tdwidth="44%">
<divalign=left><fontsize="2"color="#0000FF">姓&nbsp;名:</font></div></td>
<tdwidth="56%">
<divalign=left><fontsize="2"color="#0000FF">
<inputname=姓名>
</font></div></td>
</tr>
<tr>
<tdwidth="44%">
<divalign=left><fontsize="2"color="#0000FF">性&nbsp;别:</font></div></td>
<tdwidth="56%">
<divalign=left><fontsize="2"color="#0000FF">男
<inputCHECKED
name=性别type=radiovalue=男>

<inputname=性别
type=radiovalue=女>
</font></div></td>
</tr>
<tr>
<tdwidth="44%">
<divalign=left><fontsize="2"color="#0000FF">年&nbsp;龄:</font></div></td>
<tdwidth="56%">
<divalign=left><fontsize="2"color="#0000FF">
<inputname=年龄>
*</font></div></td>
</tr>
<tr>
<tdwidth="44%">
<divalign=left><fontsize="2"color="#0000FF">联系电话:</font></div></td>
<tdwidth="56%">
<divalign=left><fontsize="2"color="#0000FF">
<inputname=联系电话>
*</font></div></td>
</tr>
<tr>
<tdwidth="44%">
<divalign=left><fontsize="2"color="#0000FF"class="unnamed1">E-mail:</font></div></td>
<tdwidth="56%">
<divalign=left>
<pclass="unnamed1"><fontsize="2"color="#0000FF">
<inputname=Email>
*</font></p>
</div></td>
</tr>
<tr>
<tdwidth="44%"><fontsize="2"color="#0000FF">定票:</font></td>
<tdwidth="56%"><fontsize="2"color="#0000FF">
<inputname=定票id="定票"value="请输入详细内容">
</font><fontcolor="#0000FF"></font></td>
</tr>
<tr>
<tdwidth="44%">
<divalign=left><fontsize="2"color="#0000FF">定餐:</font></div></td>
<tdwidth="56%">
<divalign=left><fontsize="2"color="#0000FF">
<inputname=定餐id="定餐"value="请输入详细内容">
</font></div></td>
</tr>
<tr>
<tdwidth="44%"class="unnamed1"><fontcolor="#0000FF">定交通工具:</font></td>
<tdwidth="56%"><fontsize="2"color="#0000FF">
<inputname=定交通工具id="定交通工具"value="请输入详细内容">
</font></td>
</tr>
<tr>
<tdwidth="44%"class="unnamed1"><fontcolor="#0000FF">定房:</font></td>
<tdwidth="56%"><fontsize="2"color="#0000FF">
<inputname=定房id="定房"value="请输入详细内容">
</font></td>
</tr>
<tr>
<tdclass="unnamed1"><fontcolor="#0000FF">定导游:</font></td>
<td><fontsize="2"color="#0000FF">
<inputname=定导游id="定导游"value="请输入您想定的导游条件">
</font></td>
</tr>
<tr>
<tdclass="unnamed1"><fontcolor="#0000FF">定酒店:</font></td>
<td><fontsize="2"color="#0000FF">
<inputname=定酒店id="定酒店"value="请输入详细内容">
</font></td>
</tr>
<tr>
<tdcolspan=2>
<divalign=center><fontsize="2"color="#0000FF">
<inputname=Submittype=submitvalue=确认>
<inputname=resettype=resetvalue=取消>
</font></div></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
</form></td>
</tr>
</table>
</body>
</html>

sendmail.asp
复制代码 代码如下:
<%
functionSendMail(mailTo,mailFrom,title,content)
'onerrorresumenext
dimobjCDOMail
SetobjCDOMail=Server.CreateObject("CDONTS.NewMail")
WithobjCDOMail
.From=mailFrom
.To=mailTo
.Subject=title
.Body=content
.BodyFormat=0
.MailFormat=0
.Send
EndWith
SetobjCDOMail=Nothing
iferrthen
SendMail=False
err.Clear
else
SendMail=True
endif
endfunction

ifrequest.Form<>""then
mailTo=trim(Request.form("mailTo"))
mailForm=trim(Request.form("email"))
title=trim(Request.form("title"))
content=""
foreachmailKeyinRequest.form
content=content&"<br>"&mailKey&":"&trim(Request.form(mailKey))
next
elseifrequest.QueryString<>""then
mailTo=trim(Request.QueryString("mailTo"))
mailForm=trim(Request.QueryString("email"))
title=trim(Request.QueryString("title"))
content=""
foreachmailKeyinRequest.QueryString
content=content&"<br>"&mailKey&":"&trim(Request.QueryString(mailKey))
next
else
response.Write("<scriptlanguage=javascript>alert('请用正确的方式发送Email');window.close();</script>")
response.end
endif
'response.Write(content)
'response.End()
pdSendMail=SendMail(mailTo,mailForm,title,content)
ifnotpdSendMailthen
response.Write("<scriptlanguage=javascript>alert('发送失败');window.close();</script>")
else
response.Write("<scriptlanguage=javascript>alert('发送成功');window.close();</script>")
endif
%>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章