⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendmail.asp

📁 一个ASP做的政府网站的全站程序
💻 ASP
字号:
<%@ Language=VBScript %>
<!--#include file="connect.asp"-->
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<title>发送文章到邮箱</title>
</head>
<body>
<%
'定义相关变量
dim email
dim founderr
dim rs_article,sqlStr
fouunderr=false
dim errmsg
email=trim(Request.Form("email"))
'利用事先定义的IsValidEmail函数判断email书写是否有误
if IsValidEmail(email)=false then
   errmsg=errmsg+"<li>您的email有错误!</li>"
   founderr=true
end if
%>
<div align=center>
  <table border="0" cellspacing="0" width="85%" cellpadding="0" 
height="17" class="tableclass">  
    <tr>
      <td width="100%" >
            <%
if founderr=false then

Set rs_article=server.createobject("adodb.recordset")
sqlStr="select * from tblarticle where articleid="&request("articleid")
rs.open sqlStr,dataConn,1,1

Set JMail = Server.CreateObject("JMail.SMTPMail") 

    ' This is my local SMTP server 
    JMail.ServerAddress = "www.yhonline.net"
	JMail.Charset = "GB2312"
	JMail.ContentType = "text/html"

    ' This is me....
    JMail.Sender = "yell@icansay.com"
    JMail.Subject = rs_article("topic")

    ' Get the recipients mailbox from a form (note the lack of a equal sign).
    JMail.AddRecipient "webmaster@yhonline.net"    

    ' The body property is both read and write.
    ' If you want to append text to the body you can
    ' use JMail.Body = JMail.Body & "Hello world!"
    ' or you can use JMail.AppendText "Hello World!"
    ' which in many cases is easier to use.
    JMail.Body = rs_article("content")


    ' 1 - highest priority (Urgent)
    ' 3 - normal
    ' 5 - lowest

    JMail.Priority = 3

    JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")

    ' Must make sure that IUSR_???? has access to the following files.
    'JMail.AppendBodyFromFile "e:\mail\standard_footer.txt"
    'JMail.AddAttachment "e:\products\MyProduct.exe"

    ' Send it...
    JMail.Execute

rs_article.close
Set rs_article=nothing
    %>            
            
<p><br></p>
        <div align="center">
          <p><font size="3">文章发送成功,请再继续阅读本站其他文章;有什么问题请在论坛提出!</font></p>
          <p><font size="3">感谢您一如既往地对<b><font color="#ff0000">玉环人大(http://<A 
            href="http://www.yhonline.net">www.yhonline.net</A>)</font></b>的支持,这里的建设离不开您的意见和建议! 
            </font></p>
        </div>
            <%
response.write "</td></tr></table>"
   '假如发送过程出错,显示出错信息
else%>
        <p>&nbsp; <font color="#ff0000"><br>
          Sorry, 
            您的信息不能正确发送,请再仔细检查以下的项目是否正确:</font> 
        <ul>
      <font color="#ff0000">
                <%response.write errmsg%>
                
</font>
    </ul></td>
    </tr>
  </table>
</div>
  <dd align = "center">
    <div align="center"><br>
    </div>
<%
end if
%></dd>

</body>
</html>
<%
'判断EMAIL地址是否正确
function IsValidEmail(email)
dim names, name, i, c
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
   IsValidEmail = false
   exit function
end if
for each name in names
   if Len(name) <= 0 then
     IsValidEmail = false
     exit function
   end if
   for i = 1 to Len(name)
     c = Lcase(Mid(name, i, 1))
     if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
       IsValidEmail = false
       exit function
     end if
   next
   if Left(name, 1) = "." or Right(name, 1) = "." then
      IsValidEmail = false
      exit function
   end if
next
if InStr(names(1), ".") <= 0 then
   IsValidEmail = false
   exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
   IsValidEmail = false
   exit function
end if
if InStr(email, "..") > 0 then
   IsValidEmail = false
end if

end function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -