发邮件的asp(CDONTS.NewMail)

formmail.htm
复制代码 代码如下:




提交表单发送邮件




  
    
      
        
        
                                        width="100%">
          
            
              
                姓  名: 

              
                
                  
               

            
            
              
                性  别: 

              
                
                                                      name=性别 type=radio value=男>
                  女
                                                  type=radio value=女>
               

            
            
              
                年  龄: 

              
                
                  
                  * 

            
            
              
                联系电话: 

              
                
                  
                  * 

            
            
              
                E-mail: 

              
                
                  
                    
                    *  


              
            
            
              定票 :
               
                
               
            
            
              
                定餐: 
              
                
                  
               
            
            
              定交通工具:
              
                
              
            
            
              定房:
              
                
              
            
            
              定导游: 
              
                
               
            
            
              定酒店:
              
                
              
            
            
              
                
                  
                  
               
            
          
        
        

 


    
  




sendmail.asp
复制代码 代码如下:

<%
  function SendMail(mailTo,mailFrom,title,content)
'    on error resume next
    dim objCDOMail
    Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
    With objCDOMail
      .From =mailFrom
      .To =mailTo
      .Subject =title
      .Body =content
      .BodyFormat =0
      .MailFormat =0
      .Send
    End With
    Set objCDOMail = Nothing
    if err then
      SendMail=False
      err.Clear
    else
      SendMail=True
    end if
  end function

  if request.Form<>"" then
      mailTo=trim(Request.form("mailTo"))
      mailForm=trim(Request.form("email"))
      title=trim(Request.form("title"))
      content=""
      for each mailKey in Request.form
        content=content&"
" & mailKey & ":" & trim(Request.form(mailKey))
      next
  elseif request.QueryString<>"" then
      mailTo=trim(Request.QueryString("mailTo"))
      mailForm=trim(Request.QueryString("email"))
      title=trim(Request.QueryString("title"))
      content=""
      for each mailKey in Request.QueryString
        content=content&"
" & mailKey & ":" & trim(Request.QueryString(mailKey))
      next
  else
    response.Write("alert('请用正确的方式发送Email');window.close();")
    response.end
  end if
'  response.Write(content)
'  response.End()
  pdSendMail=SendMail(mailTo,mailForm,title,content)
  if not pdSendMail then
    response.Write("alert('发送失败');window.close();")
  else
    response.Write("alert('发送成功');window.close();")
  end if
%>

你可能感兴趣的:(发邮件的asp(CDONTS.NewMail))