ASP实现提交表单到数据库的同时以邮件形式到指定邮箱 10
以下第一段语句,是我看论坛看到的解决方案,但是我试了不行,不懂要把该语句插入到第二段的哪个位置???望高手引以指导,谢谢以下为引用的内容:<%dimobjCDOMailS...
以下第一段语句,是我看论坛看到的解决方案,但是我试了不行,不懂要把该语句插入到第二段的哪个位置???望高手引以指导,谢谢
以下为引用的内容:
<%
dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From ="xxx@hotmail.com"
objCDOMail.To =xxx@hotmail.com '接收人的邮箱(将表单内容发邮件到一固定地址)
objCDOMail.Subject ="邮件发送测试"
body=request.Form("cont") '获取表单内容
objCDOMail.Body =body
objCDOMail.BodyFormat=1 '设置为HTML格式
objCDOMail.Send
Set objCDOMail = Nothing
%>
---------------------------------------------------------------
在存入数据库前加上以上的代码,所有存入数据库的值再赋给Mail.Body 就是发送邮件的内容了!
<body>
<%
response.Write(request.Form("guestName"))
if (request.Form("guestName")<>"" and request.Form("guestContent")<>"") then
guestName=request.Form("guestName")
guestFace=request.Form("guestFace")
guestFrom=request.Form("guestFrom")
guestQQ=request.Form("guestQQ")
guestMSN=request.Form("guestMSN")
guestHomePage=request.Form("guestHomePage")
guestEmail=request.Form("guestEmail")
guestTel=request.Form("guestTel")
guestTitle=request.Form("guestTitle")
guestContent=request.Form("guestContent")
guestDatetime=now()
guestIP=request.ServerVariables("REMOTE_ADDR")
user_id=0
guestType=0 '0 留言 >0对应guest_ID留言回复
guestIsPassed=0 '0 不显示 1 显示
sql="insert into tGuestBook (guestName,guestFace,guestFrom,guestQQ,guestMSN,guestHomePage,guestEmail,guestTel,guestTitle,guestContent,guestDatetime,guestIP,user_id,guestType,guestIsPassed)values('"&guestName&"','"&guestFace&"','"&guestFrom&"','"&guestQQ&"','"&guestMSN&"','"&guestHomePage&"','"&guestEmail&"','"&guestTel&"','"&guestTitle&"','"&guestContent&"','"&guestDatetime&"','"&guestIP&"',"&user_id&","&guestType&","&guestIsPassed &")"
conn.execute(sql)
response.Write("留言成功!!<br />")
response.Write("<a href=""guestBook_add.asp"">返回</a><br />")
else
%>
<form action="" method="post" name="form1">
<table class="guestOneTopic">
<tr>
<td width="66" class="left">
名字: </td>
<td width="144" class="right"><input type="text" name="guestName" /> </td>
<td width="56" class="left"><span class="left">E-mail:</span></td>
<td width="144" class="right"><input type="text" name="guestEmail" /></td> 展开
以下为引用的内容:
<%
dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From ="xxx@hotmail.com"
objCDOMail.To =xxx@hotmail.com '接收人的邮箱(将表单内容发邮件到一固定地址)
objCDOMail.Subject ="邮件发送测试"
body=request.Form("cont") '获取表单内容
objCDOMail.Body =body
objCDOMail.BodyFormat=1 '设置为HTML格式
objCDOMail.Send
Set objCDOMail = Nothing
%>
---------------------------------------------------------------
在存入数据库前加上以上的代码,所有存入数据库的值再赋给Mail.Body 就是发送邮件的内容了!
<body>
<%
response.Write(request.Form("guestName"))
if (request.Form("guestName")<>"" and request.Form("guestContent")<>"") then
guestName=request.Form("guestName")
guestFace=request.Form("guestFace")
guestFrom=request.Form("guestFrom")
guestQQ=request.Form("guestQQ")
guestMSN=request.Form("guestMSN")
guestHomePage=request.Form("guestHomePage")
guestEmail=request.Form("guestEmail")
guestTel=request.Form("guestTel")
guestTitle=request.Form("guestTitle")
guestContent=request.Form("guestContent")
guestDatetime=now()
guestIP=request.ServerVariables("REMOTE_ADDR")
user_id=0
guestType=0 '0 留言 >0对应guest_ID留言回复
guestIsPassed=0 '0 不显示 1 显示
sql="insert into tGuestBook (guestName,guestFace,guestFrom,guestQQ,guestMSN,guestHomePage,guestEmail,guestTel,guestTitle,guestContent,guestDatetime,guestIP,user_id,guestType,guestIsPassed)values('"&guestName&"','"&guestFace&"','"&guestFrom&"','"&guestQQ&"','"&guestMSN&"','"&guestHomePage&"','"&guestEmail&"','"&guestTel&"','"&guestTitle&"','"&guestContent&"','"&guestDatetime&"','"&guestIP&"',"&user_id&","&guestType&","&guestIsPassed &")"
conn.execute(sql)
response.Write("留言成功!!<br />")
response.Write("<a href=""guestBook_add.asp"">返回</a><br />")
else
%>
<form action="" method="post" name="form1">
<table class="guestOneTopic">
<tr>
<td width="66" class="left">
名字: </td>
<td width="144" class="right"><input type="text" name="guestName" /> </td>
<td width="56" class="left"><span class="left">E-mail:</span></td>
<td width="144" class="right"><input type="text" name="guestEmail" /></td> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询