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);
}
}