发邮件的asp(CDONTS.NewMail)
发邮件的asp(CDONTS.NewMail)
发布时间:2016-12-29 来源:查字典编辑
摘要:formmail.htm复制代码代码如下:提交表单发送邮件姓名:性别:男女年龄:*联系电话:*E-mail:*定票:定餐:定交通工具:定房:...

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">姓名:</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">男

<inputCHECKED

name=性别type=radiovalue=男>

<inputname=性别

type=radiovalue=女>

</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">联系电话:</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></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

%>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ASP教程学习
热门ASP教程学习
编程开发子分类