2014-04-26 87 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的服务器上的共享空间不允许上传文件(文件夹没有默认写入权限),

注:我会加入这个为问题的评论,但我不能发表评论截至目前,所以写这个答案。


很乐意帮忙!如果您发现它有帮助,请记住接受答案。

相关问题