发邮件的asp(CDONTS.NewMail)
程序员文章站
2022-04-14 18:53:17
formmail.htm复制代码 代码如下:
formmail.htm
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>提交表单发送邮件</title>
</head>
<body>
<table width="97%" border="1" cellspacing="5" cellpadding="1" align="center" bgcolor="#eefff4" height="630">
<tr>
<td height="440">
<form action="sendmail.asp" target="_blank" method=post>
<input name="mailto" type=hidden value="dayechg@163.com">
<input name="title" type="hidden" id="title" value="网上预定">
<table border=0 cellpadding=9 cellspacing=0
width="100%">
<tbody>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">姓 名:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=姓名>
</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">性 别:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">男
<input checked
name=性别 type=radio value=男>
女
<input name=性别
type=radio value=女>
</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">年 龄:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=年龄>
*</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">联系电话:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=联系电话>
*</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff" class="unnamed1">e-mail:</font> </div></td>
<td width="56%">
<div align=left>
<p class="unnamed1"><font size="2" color="#0000ff">
<input name=email>
* </font> </p>
</div></td>
</tr>
<tr>
<td width="44%"><font size="2" color="#0000ff">定票 :</font></td>
<td width="56%"> <font size="2" color="#0000ff">
<input name=定票 id="定票" value="请输入详细内容">
</font><font color="#0000ff"> </font></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">定餐:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=定餐 id="定餐" value="请输入详细内容">
</font> </div></td>
</tr>
<tr>
<td width="44%" class="unnamed1"><font color="#0000ff">定交通工具:</font></td>
<td width="56%"><font size="2" color="#0000ff">
<input name=定交通工具 id="定交通工具" value="请输入详细内容">
</font></td>
</tr>
<tr>
<td width="44%" class="unnamed1"><font color="#0000ff">定房:</font></td>
<td width="56%"><font size="2" color="#0000ff">
<input name=定房 id="定房" value="请输入详细内容">
</font></td>
</tr>
<tr>
<td class="unnamed1"><font color="#0000ff">定导游:</font> </td>
<td><font size="2" color="#0000ff">
<input name=定导游 id="定导游" value="请输入您想定的导游条件">
</font> </td>
</tr>
<tr>
<td class="unnamed1"><font color="#0000ff">定酒店:</font></td>
<td><font size="2" color="#0000ff">
<input name=定酒店 id="定酒店" value="请输入详细内容">
</font></td>
</tr>
<tr>
<td colspan=2>
<div align=center><font size="2" color="#0000ff">
<input name=submit type=submit value=确认>
<input name=reset type=reset value=取消>
</font> </div></td>
</tr>
</tbody>
</table>
<p> </p>
</form></td>
</tr>
</table>
</body>
</html>
sendmail.asp
<%
function sendmail(mailto,mailfrom,title,content)
' on error resume next
dim objcdomail
set objcdomail = server.createobject("cdonts.newmail")
with objcdomail
.from =mailfrom
.to =mailto
.subject =title
.body =content
.bodyformat =0
.mailformat =0
.send
end with
set objcdomail = nothing
if err then
sendmail=false
err.clear
else
sendmail=true
end if
end function
if request.form<>"" then
mailto=trim(request.form("mailto"))
mailform=trim(request.form("email"))
title=trim(request.form("title"))
content=""
for each mailkey in request.form
content=content&"<br>" & mailkey & ":" & trim(request.form(mailkey))
next
elseif request.querystring<>"" then
mailto=trim(request.querystring("mailto"))
mailform=trim(request.querystring("email"))
title=trim(request.querystring("title"))
content=""
for each mailkey in request.querystring
content=content&"<br>" & mailkey & ":" & trim(request.querystring(mailkey))
next
else
response.write("<script language=javascript>alert('请用正确的方式发送email');window.close();</script>")
response.end
end if
' response.write(content)
' response.end()
pdsendmail=sendmail(mailto,mailform,title,content)
if not pdsendmail then
response.write("<script language=javascript>alert('发送失败');window.close();</script>")
else
response.write("<script language=javascript>alert('发送成功');window.close();</script>")
end if
%>
复制代码 代码如下:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>提交表单发送邮件</title>
</head>
<body>
<table width="97%" border="1" cellspacing="5" cellpadding="1" align="center" bgcolor="#eefff4" height="630">
<tr>
<td height="440">
<form action="sendmail.asp" target="_blank" method=post>
<input name="mailto" type=hidden value="dayechg@163.com">
<input name="title" type="hidden" id="title" value="网上预定">
<table border=0 cellpadding=9 cellspacing=0
width="100%">
<tbody>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">姓 名:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=姓名>
</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">性 别:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">男
<input checked
name=性别 type=radio value=男>
女
<input name=性别
type=radio value=女>
</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">年 龄:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=年龄>
*</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">联系电话:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=联系电话>
*</font> </div></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff" class="unnamed1">e-mail:</font> </div></td>
<td width="56%">
<div align=left>
<p class="unnamed1"><font size="2" color="#0000ff">
<input name=email>
* </font> </p>
</div></td>
</tr>
<tr>
<td width="44%"><font size="2" color="#0000ff">定票 :</font></td>
<td width="56%"> <font size="2" color="#0000ff">
<input name=定票 id="定票" value="请输入详细内容">
</font><font color="#0000ff"> </font></td>
</tr>
<tr>
<td width="44%">
<div align=left><font size="2" color="#0000ff">定餐:</font> </div></td>
<td width="56%">
<div align=left><font size="2" color="#0000ff">
<input name=定餐 id="定餐" value="请输入详细内容">
</font> </div></td>
</tr>
<tr>
<td width="44%" class="unnamed1"><font color="#0000ff">定交通工具:</font></td>
<td width="56%"><font size="2" color="#0000ff">
<input name=定交通工具 id="定交通工具" value="请输入详细内容">
</font></td>
</tr>
<tr>
<td width="44%" class="unnamed1"><font color="#0000ff">定房:</font></td>
<td width="56%"><font size="2" color="#0000ff">
<input name=定房 id="定房" value="请输入详细内容">
</font></td>
</tr>
<tr>
<td class="unnamed1"><font color="#0000ff">定导游:</font> </td>
<td><font size="2" color="#0000ff">
<input name=定导游 id="定导游" value="请输入您想定的导游条件">
</font> </td>
</tr>
<tr>
<td class="unnamed1"><font color="#0000ff">定酒店:</font></td>
<td><font size="2" color="#0000ff">
<input name=定酒店 id="定酒店" value="请输入详细内容">
</font></td>
</tr>
<tr>
<td colspan=2>
<div align=center><font size="2" color="#0000ff">
<input name=submit type=submit value=确认>
<input name=reset type=reset value=取消>
</font> </div></td>
</tr>
</tbody>
</table>
<p> </p>
</form></td>
</tr>
</table>
</body>
</html>
sendmail.asp
复制代码 代码如下:
<%
function sendmail(mailto,mailfrom,title,content)
' on error resume next
dim objcdomail
set objcdomail = server.createobject("cdonts.newmail")
with objcdomail
.from =mailfrom
.to =mailto
.subject =title
.body =content
.bodyformat =0
.mailformat =0
.send
end with
set objcdomail = nothing
if err then
sendmail=false
err.clear
else
sendmail=true
end if
end function
if request.form<>"" then
mailto=trim(request.form("mailto"))
mailform=trim(request.form("email"))
title=trim(request.form("title"))
content=""
for each mailkey in request.form
content=content&"<br>" & mailkey & ":" & trim(request.form(mailkey))
next
elseif request.querystring<>"" then
mailto=trim(request.querystring("mailto"))
mailform=trim(request.querystring("email"))
title=trim(request.querystring("title"))
content=""
for each mailkey in request.querystring
content=content&"<br>" & mailkey & ":" & trim(request.querystring(mailkey))
next
else
response.write("<script language=javascript>alert('请用正确的方式发送email');window.close();</script>")
response.end
end if
' response.write(content)
' response.end()
pdsendmail=sendmail(mailto,mailform,title,content)
if not pdsendmail then
response.write("<script language=javascript>alert('发送失败');window.close();</script>")
else
response.write("<script language=javascript>alert('发送成功');window.close();</script>")
end if
%>
推荐阅读
-
flash和asp分页的一点心得与flash脚本
-
改进性能和样式的24个ASP 技巧
-
学习ASP和编程的28个观点
-
详解ASP.NET数据绑定操作中Repeater控件的用法
-
ASP.NET框架中的数据绑定概要与数据绑定表达式的使用
-
总结Visual Studio下ASP.NET模板化控件中的数据绑定
-
Asp.Net(C#)使用oleDbConnection 连接Excel的方法
-
解读ASP.NET 5 & MVC6系列教程(12):基于Lamda表达式的强类型Routing实现
-
Mac中体验ASP.NET 5 beta2的K gen代码生成
-
ASP.NET Web Api 2实现多文件打包并下载文件的实例