在本机用CDONTS发送邮件

email.asp  
    
    
    
    
    
  给我Email  
    
    
    
    
    
    
    
            bordercolordark="#ECF5FF"   bordercolorlight="#6898D0">  
              
                  
                    
                          
                          给   我   Email  
                        
                          
                          大   名:  
                              
                                
                              *     
                        
                          
                          发件人:  
                              
                                
                              *     
                        
        
                          收件人:  
                              
                                
                              *     
                        
                          
                          主   题:  
                              
                                
                            
                        
                          
                          内   容:  
                              
                                
                              *     
                        
                          
                            
                                 
                        
                    
                
            
              
                  
                    
                       
                            type="reset"   value="重写"   name="rstReferral"   class="buttonface">  
                
            
        
      
  
    
    
    
    
....................................................................................................................
sentmail.asp  
    
    
    
    
  给我Email  
    
    
    
  <%  
  dim   username  
  dim   email,mubiaoEmailAddress  
  dim   title  
  dim   content  
  dim   founderr  
  fouunderr=false  
  dim   errmsg  
  username=trim(Request.form("username"))  
  email=trim(Request.Form("email"))  
  title=trim(Request.Form("title"))  
  mubiaoEmailAddress=trim(Request.Form("mubiaoEmailAddress"))  
  content=Request.Form("content")  
  if   username=""   then  
        errmsg="
  • 您的大名不能为空
  • "  
            founderr=true  
      end   if  
      if   IsValidEmail(email)=false   then  
            errmsg=errmsg+"
  • 您的email有错误,否则没办法回复您的Email
  • "  
            founderr=true  
      end   if  
      if   content=""   then  
            errmsg=errmsg+"
  • 内容不能为空
  • "  
            founderr=true  
      end   if  
      %>  
        
            height="17"   class="tableclass">  
                
                
                      
      <%  
      if   founderr=false   then  
      dim     objCDOMail  
      Set   objCDOMail   =   Server.CreateObject("CDONTS.NewMail")  
      response.write   Email  
      response.write   mubiaoEmailAddress  
        
        
      objCDOMail.From   =Email          
      objCDOMail.To   =   mubiaoEmailAddress        
      objCDOMail.Subject   =title      
      objCDOMail.Body   =   content          
      objCDOMail.Send  
      Set   objCDOMail   =   Nothing  
        
      %>  
      


      
                        
                          

    谢谢您的Email,xx会尽快处理您的Email,请再继续访问这里的其他栏目;

      
                          

    感谢您一如既往地对ASP123的支持,这里的建设离不开您的意见和建议!    
                              

      
                      
      
      <%  
      response.write   ""  
      else  
      'end   if  
      %>  
                      

       
      
                          Sorry,   请再仔细检查以下的项目是否正确:    
                      

        
                    <%response.write   errmsg%>  
          
                
      
                
            
      
      
        
        
                bordercolordark="#ecf5ff"   bordercolorlight="#6898d0">  
                  
                      
                        
                              
                              给    
                                  我   Email  
                            
                              
                              大   名:  
                                  
                                    
                                  *     
                            
                              
                              E-mail:  
                                  
                                    
                                  *     
                            
                              
                              主   题:  
                                  
                                    
                                
                            
                              
                              内   容:  
                                  
                                  <%=content%>  
                                  *     
                            
                              
                                
                                     
                            
                        
                    
                
                  
                      
                        
                                type="reset"   value="重写"   name="rstReferral"   class="buttonface">  
                    
                
            
            
              
      
              
      
        
      <%  
      end   if  
      %>  
        
        
        
      <%  
      function   IsValidEmail(email)  
        
      dim   names,   name,   i,   c  
        
      'Check   for   valid   syntax   in   an   email   address.  
        
      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  
      %>


    [本日志由 wang 于 2009-09-25 09:30 AM 编辑]
    上一篇: Windows2003 IIS+PHP+MySQL配置
    下一篇: ASP中连接数据库的5种方法
    文章来自: 本站原创
    引用通告: 查看所有引用 | 我要引用此文章
    Tags:
    相关日志:
    评论: 0 | 引用: 0 | 查看次数: 1604
    发表评论
    昵 称:
    密 码: 游客发言不需要密码.
    邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
    网 址: 输入网址便于回访.
    内 容:
    验证码:
    选 项:
    虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
    字数限制 300 字 | UBB代码 开启 | [img]标签 关闭