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())); Fileupload1.PostedFile.SaveAs(Server.MapPath("~\\File\\" + FileName.Trim())); string path = "~\\File\\" + FileName; lblUpload.Text = "file is uploaded"; Attachment mail1 = new Attachment(Server.MapPath("~\\File\\" + FileName.Trim())); obj.Attachments.Add(mail1); } else { lblUpload.Text = "file not uploaded"; } SmtpClient smt = new SmtpClient("smtp.gmail.com",465 ); smt.EnableSsl = true; smt.Timeout = 10000; smt.UseDefaultCredentials = false; smt.Credentials = new System.Net.NetworkCredential(txtFrom.Text, txtPwd.Text, "www.gmail.com"); smt.DeliveryMethod = SmtpDeliveryMethod.Network; obj.BodyEncoding = UTF8Encoding.UTF8; smt.Credentials = CredentialCache.DefaultNetworkCredentials; try { smt.Send(obj); } catch(Exception e1) // The operation has timed out. { throw e1; }
Attachment mail1 = new Attachment(Server.MapPath("~\\File\\" + FileName.Trim());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)