ASP提交留言直接发到指定邮箱(二),现有基础修改

如果网站已经在运行了.且留言是保存到数据库的.现在需要修改的.不防看看下边的文章:

这段代码为演示.如现在的网站留言本样式(具体参照自己的):

<table width="600" border="0" align="center" cellpadding="4" cellspacing="1">
<form action="savegb.asp" method="post" name="add">
  <tr>
    <td>称呼:<input name="name" type="text" id="name"></td>
  </tr>
  <tr>
    <td>电话:<input name="tel" type="text" id="tel"></td>
  </tr>
  <tr>
    <td>标题:<input name="title" type="text" id="title"></td>
  </tr>
  <tr>
    <td><input name="button" type="submit" id="button" value="提交"></td>
  </tr>
  </form>
</table>
---------------------------------------------------------------------------------------------------------

那么请在您的savegb.asp文件 <% %>中加入如下代码:

代码开始

<%
if request("button")="提交" then
Set msg = Server.CreateObject("JMail.Message")
msg.silent = true
msg.Logging = true
msg.Charset = "gb2312"
msg.ContentType = "text/html" '邮件的格式为HTML的
msg.MailServerUserName ="hr" ''输入smtp服务器验证登陆名 (例如邮箱为:hr@hnihr.com)
msg.MailServerPassword ="123456" ''输入smtp服务器验证密码   (用户Email帐号对应的密码)
msg.From ="hr@hnihr.com"'   ''发件人Email
msg.FromName ="易阳网络"' ''发件人姓名
msg.AddRecipient "317970602.com" ''收件人Email
msg.Subject ="信件主题"' ''信件主题
msg.Body ="称呼:"& request("name") &"<br>电话:"& request("tel") &"<br>标题:"& request("title")   ''正文
msg.Send ("mail.hnihr.com") ''smtp服务器地址(例如邮箱为:*@163.com的smtp服务器地址为smtp.163.com)
set msg = nothing
response.Write("<script>alert('发送成功!');</script>")
end if
%>

引用地址:

post by 不懂戀愛魚兒 | 2009年6月15日 | 归档于 [Asp技术]
  1. 2010-01-12 16:43| #3

    谢谢啦,帮我解决了个大问题 。THANK YOU~

    博主回复:8k7.欢迎常来逛逛
  2. 木鱼
    2009-12-04 13:06| #2

    只有一个文件保存在哪里???

  3. 2009-11-24 16:33| #1

    分享了!!!!!!!!谢谢

发表评论