关闭

直接发到邮箱的代码

60人阅读 评论(0) 收藏 举报
分类:

表单部分:

 

<table width="90%"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <th scope="col"> <FORM action=sendmail.asp
                                encType=text/plain name=myform id="myform" 客户留言?>
                <TABLE border=0 cellPadding=0 cellSpacing=10
                                width="100%">
                  <TBODY>
                    <TR class=unnamed2>
                      <TD align=right height=25>&nbsp;</TD>
                      <TD height=25><span class="STYLE1">带**</span>必填</TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right height=25 width="10%"><div align="right">姓名:</div></TD>
                      <TD height=25 width="69%"><div align="left">
                          <INPUT id=姓名3
                                name=name size=29>
                          <span class="STYLE1">**</span></div></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right><div align="right">性别:</div></TD>
                      <TD><input type="radio" name="sex" value="男" checked>
                        先生
                        <input type="radio" name="sex" value="女">
                        小姐</TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right width="10%"><div align="right">单位:</div></TD>
                      <TD width="69%"><div align="left">
                          <INPUT id=单位2 name=company size=29>
                          <span class="STYLE1">**</span></div></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right width="10%"><div align="right">地址:</div></TD>
                      <TD width="69%"><div align="left">
                          <INPUT name=add id="add" size=29>
                          <span class="STYLE1">**</span></div></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right height=12 vAlign=center><div align="right">邮编:</div></TD>
                      <TD height=12><input name="zipcode" type="text" id="zipcode" value="邮编" size="16"></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right height=12 vAlign=center><div align="right">网址:</div></TD>
                      <TD height=12><input name="website" type="text" id="website" value="请填写您公司或您的网站网址" size="29"></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right height=12 vAlign=center
                                width="10%"><div align="right">邮箱:</div></TD>
                      <TD height=12 width="69%"><div align="left">
                          <INPUT id=电子邮箱2
                                name=email size=29>
                          <span class="STYLE1">**</span></div></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right width="10%"><div align="right">电话:</div></TD>
                      <TD width="69%"><div align="left">
                          <INPUT id=电话2 name=tel size=29>
                          <span class="STYLE1">**</span></div></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right width="10%"><div align="right">传真:</div></TD>
                      <TD width="69%"><div align="left">
                          <INPUT name=fax id="fax" size=29>
                      </div></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right><div align="right">标题:</div></TD>
                      <TD><INPUT name=title id="title" size=29>
                          <span class="STYLE1">**</span></TD>
                    </TR>
                    <TR class=unnamed2>
                      <TD align=right height=2 width="10%"><div align="right">留言:</div></TD>
                      <TD height=2 width="69%"><TEXTAREA cols=40 id=message name=message rows=7 wrap=VIRTUAL></TEXTAREA>
                          <span class="STYLE1">**</span> </TD>
                    </TR>
                    <TR>
                      <TD class=d123 colSpan=2 height=2><DIV align=center><FONT size=2>            <BR>
                                <INPUT name=B1 type=submit value=发送>
                                <INPUT name=B2 type=reset value=清除>
                      </FONT></DIV></TD>
                    </TR>
                    <TR>
                      <TD class=d123 colSpan=2 height=293>&nbsp;</TD>
                    </TR>
                  </TBODY>
                </TABLE>
            </FORM></th>
          </tr>
        </table>

 

 

ASP代码部分:

 

<%

rcompany=Trim(Request("company"))
rEmail=Trim(Request("email"))
rname=trim(request("name"))
rtitle=trim(request("title"))

rTel=trim(request("tel"))
rFax=trim(request("fax"))
rAdd=trim(request("add"))
rzipcode=trim(request("zipcode"))
rWebsite=trim(request("website"))
rmessage=trim(request("message"))
Content="公司:"&rcompany&chr(13)&chr(10)&"联系人:"&rname&chr(13)&chr(10)&"电话:"&rTel&chr(13)&chr(10)&"传真:"&rFax&chr(13)&chr(10)
Content=Content&"E-mail:"&remail&chr(13)&chr(10)&"地址:"&radd&chr(13)&chr(10)&"邮编:"&rzipcode&chr(13)&chr(10)&"网址:"&rwebsite&chr(13)&chr(10)
Content=Content&"信息标题:"&rtitle&chr(13)&chr(10)&"内容:"&rmessage&chr(13)&chr(10)

if rcompany<>"" and remail<>"" then
 Set msg = Server.CreateObject("JMail.Message")
 msg.silent = true
 msg.Logging = true
 msg.Charset = "gb2312"
 msg.MailServerUserName = "gd_nick" ''输入smtp服务器验证登陆名 (邮局中任何一个用户的Email地址)
 msg.MailServerPassword = "nick.w.l" ''输入smtp服务器验证密码 (用户Email帐号对应的密码)
 msg.From = "gd_nick@tom.com" 'Request.Form("email") ''发件人Email
 msg.FromName = ""&rtitle&"" 'Request.Form("name") ''发件人姓名
 msg.AddRecipient "bjc@gzbjc.com.cn" ''收件人Email
 msg.Subject = rtitle 'Request.Form("subject") ''信件主题
 msg.Body = Content 'Request.Form("body") ''正文
 msg.Send ("smtp.tom.com") ''smtp服务器地址(企业邮局地址)
 set msg = nothing
 response.Write "<script language=javascript>alert('您的信息已经成功发送,我们在收到您的信息后会尽快与您联系,谢谢!');"
 response.Write "javascript:window.location='contact.htm';</script>"
else
 response.Write "<script language=javascript>alert('请填写完整的留言信息!');"
 response.Write "javascript:history.go(-1);</script>"
end if
 %>

 

 

方法二:

dim CLStr,msg,mailserver,username,password,receive
CLStr=Chr(13) & Chr(10)
'请在此修改相关信息
 mailserver="smtp.163.com" '邮局服务器地址(smtp服务器地址)
 username=xxxxxxxxxx@163.com 'smtp服务器验证登陆名(用来做为代发邮件的地址)
 password="xxxxxx" 'smtp服务器验证密码 (信箱密码)
 receive="xxxxx@163.com '接受反馈信息的email地址(用来接收邮件的信箱)
'修改结束
Set msg = Server.CreateObject("JMail.Message")
msg.Charset = "gb2312"
msg.logging = true '启用邮件日志
msg.silent=True'屏蔽例外错误,返回False或True
'msg.ContentType = "text/html"'邮件的格式为HTML格式
msg.Priority = 1 '邮件等级,1为加急,3为普通,5为低级
msg.MailServerUserName = username
msg.MailServerPassword = password
msg.From = username
msg.FromName = username
msg.AddRecipient (receive)

msg.Subject = "网站订单:"&inBillNo
msg.HTMLBody = "网站订单:"&CLStr&CLStr
msg.HTMLBody = msg.HTMLBody&""&inBillNo&"&nbsp;&nbsp;<a href='http://www.qqbear.com.cn/vieworder.asp?action=list&ID="&inBillNo&"'>查看</a>"
'msg.HTMLBody = msg.HTMLBody&"<br>对方信箱:"&Request.Form("email")&CLStr
'msg.HTMLBody = msg.HTMLBody&"<br>留言内容:<br>"
'msg.HTMLBody = msg.HTMLBody&"<div style='font:9pt;background-color:#eeeeee'>"&Request.Form("content")&CLStr
msg.HTMLBody = msg.HTMLBody&"</div>"
If msg.Send (mailserver) Then
Response.Write(" <script language=javascript>alert('发送成功');location='../main_en.asp?menu=1'</script>")
else
Response.Write(" <script language=javascript>alert('发送失败,请仔细检查邮件服务器的设置是否正确!') </script>")
end if
msg.close
set msg = nothing

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:349847次
    • 积分:4303
    • 等级:
    • 排名:第7027名
    • 原创:775篇
    • 转载:136篇
    • 译文:1篇
    • 评论:20条
    最新评论