private void SendMail(string strSubject,string strBody,string strToMail,string strFromMail)
{
MailMessage mailObj=new MailMessage();
mailObj.From=strFromMail;
mailObj.To=strToMail;
mailObj.BodyFormat=MailFormat.Html;mailObj.Subject=strSubject;
mailObj.Body=strBody;//SmtpMail.SmtpServer="170.60.245.90";
SmtpMail.SmtpServer="smtp.163.com";mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","admin"); 
//mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","password");
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","myselfmail"); 
mailObj.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","mailpwd");
try
{
SmtpMail.Send(mailObj); 
}
catch(Exception ex)
{
throw(ex);}
}
-------------------------private void Button1_Click(object sender, System.EventArgs e)
{
string strToMail = "[email protected]";
//string strFromMail = "admin";
string strFromMail = "[email protected]";string strSubject = "为啥在我这里就可以呢?";
string strBody = "你看我这里就可以,啥都没动哎!";SendMail(strSubject,strBody,strToMail,strFromMail);
}--------
这样发mail,我在我自己的电脑上试就可以,防火墙是瑞星。但是到了客户那里,老是报错,说是未能找到指定文件.
客户那里控制的特别的严格,再怎么说也应该让我发送出去,大不了给当成垃圾邮件阿!
可是总是throw exception
但是我不知道为什么会出异常。大家遇到过吗?

解决方案 »

  1.   

    see System.Web.Mail FAQhttp://www.systemwebmail.com/faq.aspx
      

  2.   

    找不到指定的模块。 
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: 找不到指定的模块。Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  Stack Trace: 
    [FileNotFoundException: 找不到指定的模块。]
       Mailtest.WebForm1.SendMail(String strSubject, String strBody, String strToMail, String strFromMail) in c:\inetpub\wwwroot\mailtest\webform1.aspx.cs:90
       Mailtest.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\mailtest\webform1.aspx.cs:61
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain() +1277