Hello,
I have created a module that send email with attachment locally it works fine but on the webserver(godaddy) it doesn't work. I got this error.
A critical error has occurred. Empty path name is not legal.
privatevoid SendEmailNotification2()
{
string to = "careers@domain.com";
string from = "job@hotmail.com";
string subject = "CV from Web Site";
string body = "New CV from Web Site";
using (MailMessage mm = newMailMessage(txtEmail.Text, "careers@domain.com"))
{
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("job111@gmail.com", "Password");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
// ClientScript.RegisterStartupScript(GetType(), "alert", "alert('Email sent.');", true);
}
}