做一个网站的Contact Us页面,提交以后的部分代码如下:MailMessage MyMail = new MailMessage();
MyMail.From = "[email protected]";
MyMail.To = "[email protected]";
MyMail.Subject = "Notice";
MyMail.Body = 表单信息;
MyMail.Cc = "";
MyMail.Bcc = "";
MyMail.UrlContentBase = "";
MyMail.UrlContentLocation = "";
MyMail.BodyEncoding = Encoding.UTF8;
MyMail.BodyFormat = MailFormat.Html;
MyMail.Priority = MailPriority.Normal;SmtpMail.Send(MyMail);感觉代码应该没有什么问题.在某些机器上运行正常,而有些机器上访问的时候,提交后收不到信.请问各位谁知道是什么原因?

解决方案 »

  1.   

    没有设置SMTP服务器,默认是用本地的.
      

  2.   

    收信会有延迟的,另外你的smtp服务器配置正确否?里面有设置邮件接收对象的.
    你可在C:\Inetpub\mailroot\Queue目录下看看有没有信件滞留.
      

  3.   


    MailMessage MyMail = new MailMessage();
    MyMail.From = "[email protected]";
    MyMail.To = "[email protected]";
    MyMail.Subject = "Notice";
    MyMail.BodyFormat =MailFormat.Text;
    MyMail.Body = "表单信息";
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication 
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "zhang san"); //set your username here 
    message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "123456"); //set your password here 
    SmtpMail.SmtpServer ="smtp.163.com";
    SmtpMail.Send(MyMail);
    try 

    SmtpMail.Send(message); 

    catch( System.Web.HttpException exHttp ) 

    //
    }
      

  4.   

    你没有设置发送帐户的用户、口令。当然,SMTP服务器的地址也是必须要设置的。
      

  5.   

    http://blog.csdn.net/wthorse/archive/2006/06/13/794705.aspx
    我这个反正是运行好好的.(邮件地址改)
    另:邮件服务器配置得注意
      

  6.   

    给你贴个xp配置的Set Up and Configure an SMTP Virtual Server in Windows XPSUMMARY
    This step-by-step article describes how to set up a Simple Mail Transfer Protocol (SMTP) virtual server on a Windows XP-based computer. Microsoft SMTP Service uses the Internet-standard SMTP to transport and deliver mail messages. Microsoft SMTP Service does not support the use of individual mailboxes; it places incoming messages in a Drop folder or it forwards them to other SMTP servers (if the message is addressed to a remote domain). This feature allows Microsoft SMTP Service to be used as a mail receiver for other programs. 
    Install Microsoft Internet Information Services (IIS) and Microsoft SMTP Service
    Because Microsoft SMTP Service is a component of Microsoft Internet Information Services (IIS), you must install IIS to use Microsoft SMTP Service. To install IIS and Microsoft SMTP service, follow these steps:
    1. Click Start, point to Settings, and then click Control Panel. 
    2. Double-click Add/Remove Programs. 
    3. Click Add/Remove Windows Components. 
    4. In the Windows Components Wizard, click Internet Information Services (IIS), and then click Details. 
     
    5. Click to select the following check boxes:
    • Common Files 
    • Documentation 
    • Internet Information Services Snap-In 
    • SMTP Service 
    • World Wide Web Server   
    6. Click OK, and then click Next on the Windows Components page. 
    7. On the Completing the Windows Components Wizard page, click Finish. 
    8. Click Close. Configure the SMTP Virtual Server
    When you install Microsoft SMTP Service, a default SMTP virtual server is created to handle basic mail delivery functions. The SMTP virtual server is automatically configured with default settings that enable it to accept local client computer connections and to process messages. You can accept the default settings only need change a little.To grant or deny permissions to relay messages through the SMTP virtual server, follow these steps: 
    1. Click Start, point to Programs, point to Administrative Tools, and then click Internet Services Manager. 
    2. Alternatively, start the IIS snap-in. 
    3. Right-click Default SMTP Virtual Server, and then click Properties. 
    4. Click the Access tab. 
    5. Under Relay restrictions, click Relay. 
    6. Please select the second option:
    • Click Only the list below. 
    • Click All except the list below. 
     
    7. click OK .