protected void btnSubmit_Click(object sender, EventArgs e) { MailMessage obj = new MailMessage(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text); if (Fileupload1.HasFile) { String FileName = Path.GetFileName(Fileupload1.PostedFile.FileName); Fileupload1.PostedFile.SaveAs(Server.MapPath("~\\File\\" + FileName.Trim())); // " string path = "~\\File\\" + FileName.Trim(); // " lblUpload.Text = "file is uploaded"; Attachment mail1 = new Attachment(path); // DirectoryNotFoundException file or directory cannot be found. obj.Attachments.Add(mail1); } else { lblUpload.Text = "file not uploaded"; } SmtpClient smt = new SmtpClient(); smt.Port = 587; smt.Port = 465; smt.Host = "smtp.gmail.com"; smt.Host = "smtp.mail.yahoo.com"; smt.Host = "smtp.live.com"; smt.EnableSsl = true; smt.UseDefaultCredentials = false; smt.Credentials = new System.Net.NetworkCredential(txtFrom.Text, txtPwd.Text); try { smt.Send(obj); } catch(Exception e1)// System.Net.Mail.SmtpException Failur sending mail { throw e1; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)