2014-04-26 109 views
0

我創建了一個模塊,發送附件本地電子郵件它工作正常,但在網絡服務器(godaddy)它無法正常工作。我有這個錯誤。文件上傳工作本地主機但不是godaddy服務器(dnn網站)

發生嚴重錯誤。空路徑名稱不合法。

private void SendEmailNotification2() 
{ 
    string to = "[email protected]"; 
    string from = "[email protected]"; 
    string subject = "CV from Web Site"; 
    string body = "New CV from Web Site"; 

    using (MailMessage mm = newMailMessage(txtEmail.Text, "[email protected]")) 
    { 
     mm.Subject = "ssss"; 
     mm.Body = "baaa"; 
     if (FileUpload1.HasFile) 
     { 
      string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName); 
      mm.Attachments.Add(newAttachment(FileUpload1.PostedFile.InputStream, FileName)); 
     } 

     mm.IsBodyHtml = false; 
     SmtpClient smtp = newSmtpClient(); 
     smtp.Host = "smtp.gmail.com"; 
     smtp.EnableSsl = true; 
     ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { returntrue; }; 
     NetworkCredential NetworkCred = newNetworkCredential("[email protected]", "Password"); 
     smtp.UseDefaultCredentials = true; 
     smtp.Credentials = NetworkCred; 
     smtp.Port = 587; 
     smtp.Send(mm); 
     // ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true); 
    } 
} 

回答

1

你能上傳服務器上的文件嗎? 通過默認GoDaddy的服務器上的共享空間不允許上傳文件(文件夾沒有默認寫入權限),

注:我會加入這個爲問題的評論,但我不能發表評論截至目前,所以寫這個答案。


很樂意幫忙!如果您發現它有幫助,請記住接受答案。

相關問題