<%@  Import  Namespace="System.Web.Mail"  %>  
<Script  Language="VB"  Runat="Server">  
   Sub  Send(sender  As  Object,  e  As  EventArgs)  
       Dim  objMail  As  New  MailMessage()  
 
       '指定邮件发件人及收件人  
       objMail.From  =  "[email protected]"  
       objMail.To  =  "[email protected]"  
       objMail.Subject  =  "123  "                    '指定邮件主题  
       objMail.Body  =  "452342342"                        '指定邮件内容  
       '使用  SmtpMail  类来发送邮件  
       SmtpMail.SmtpServer  =  "localhost"            '指定  SMTP  服务器  
       SmtpMail.Send(objMail)  
   End  Sub  
</Script>  
<Html>  
 
   <Body>  
           <Form  Runat="Server">  
   <Asp:Button  Runat="Server"    text="发送"  OnClick="Send"  />  
       </Form>  
   </Body>  
</Html>  
 
如果    SmtpMail.SmtpServer  =  "localhost"        
 
出现的错误为  
 
服务器拒绝了一个或多个收件人地址。服务器响应为:  550  5.7.1  Unable  to  relay  for  [email protected]    
 
如果SmtpMail.SmtpServer  =  "seed.net.tw"    
 
出现的错误为  
 
与服务器的传输连接失败。  
 
请高手指点    我应该怎么解决这个问题    ?  

解决方案 »

  1.   

    你用的SmtpServer有可能是需要身份验证才能发送的 添加下面代码在SmtpMail.SmtpServer  =  "seed.net.tw"    之前
    objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
    objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", 邮件帐户名); //set your username here 
    objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", 密码); //set your password here
      

  2.   

    大哥 我用VB.net作的  你那个  是用C#做的