发邮件的asp(CDONTS.NewMail)

2018-09-06 12:53

阅读:531

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

<body>
<tablewidth=97%border=1cellspacing=5cellpadding=1align=centerbgcolor=#EEFFF4height=630>
<tr>
<tdheight=440>
<formaction=sendMail.aspmethod=post>
<inputname=titletype=hiddenid=titlevalue=网上预定>
<tableborder=0cellpadding=9cellspacing=0
width=100%>
<tbody>
<tr>
<tdwidth=44%>
<divalign=left><fontsize=2color=#0000FF>姓名:</font></div></td>
<tdwidth=56%>
<divalign=left><fontsize=2color=#0000FF>
<inputname=姓名>
</font></div></td>
</tr>
<tr>
<tdwidth=44%>
<divalign=left><fontsize=2color=#0000FF>性别:</font></div></td>
<tdwidth=56%>
<divalign=left><fontsize=2color=#0000FF>男
<inputCHECKED
name=性别type=radiovalue=男>

<inputname=性别
type=radiovalue=女>
</font></div></td>
</tr>
<tr>
<tdwidth=44%>
<divalign=left><fontsize=2color=#0000FF>年龄:</font></div></td>
<tdwidth=56%>
<divalign=left><fontsize=2color=#0000FF>
<inputname=年龄>
*</font></div></td>
</tr>
<tr>
<tdwidth=44%>
<divalign=left><fontsize=2color=#0000FF>联系电话:</font></div></td>
<tdwidth=56%>
<divalign=left><fontsize=2color=#0000FF>
<inputname=联系电话>
*</font></div></td>
</tr>
<tr>
<tdwidth=44%>
<divalign=left><fontsize=2color=#0000FFclass=unnamed1>E-mail:</font></div></td>
<tdwidth=56%>
<divalign=left>
<pclass=unnamed1><fontsize=2color=#0000FF>
<inputname=Email>
*</font></p>
</div></td>
</tr>
<tr>
<tdwidth=44%><fontsize=2color=#0000FF>定票:</font></td>
<tdwidth=56%><fontsize=2color=#0000FF>
<inputname=定票id=定票value=请输入详细内容>
</font><fontcolor=#0000FF></font></td>
</tr>
<tr>
<tdwidth=44%>
<divalign=left><fontsize=2color=#0000FF>定餐:</font></div></td>
<tdwidth=56%>
<divalign=left><fontsize=2color=#0000FF>
<inputname=定餐id=定餐value=请输入详细内容>
</font></div></td>
</tr>
<tr>
<tdwidth=44%class=unnamed1><fontcolor=#0000FF>定交通工具:</font></td>
<tdwidth=56%><fontsize=2color=#0000FF>
<inputname=定交通工具id=定交通工具value=请输入详细内容>
</font></td>
</tr>
<tr>
<tdwidth=44%class=unnamed1><fontcolor=#0000FF>定房:</font></td>
<tdwidth=56%><fontsize=2color=#0000FF>
<inputname=定房id=定房value=请输入详细内容>
</font></td>
</tr>
<tr>
<tdclass=unnamed1><fontcolor=#0000FF>定导游:</font></td>
<td><fontsize=2color=#0000FF>
<inputname=定导游id=定导游value=请输入您想定的导游条件>
</font></td>
</tr>
<tr>
<tdclass=unnamed1><fontcolor=#0000FF>定酒店:</font></td>
<td><fontsize=2color=#0000FF>
<inputname=定酒店id=定酒店value=请输入详细内容>
</font></td>
</tr>
<tr>
<tdcolspan=2>
<divalign=center><fontsize=2color=#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
%>


评论


亲,登录后才可以留言!