if (fileAttachement.PostedFile != null) { // Get a reference to PostedFile object HttpPostedFile ulFile = fileAttachement.PostedFile; // Get size of the file int nFileLen = ulFile.ContentLength; // Make sure the size of the file is > 0 if (nFileLen > 0) { // Get the file name FileName = Path.GetFileName(fileAttachement.PostedFile.FileName); // Preced the file name with "attachments/" so // the file is saved to our attachments directory FileName = "AttachedFiles/" + FileName; // Save the file on the server fileAttachement.PostedFile.SaveAs(Server.MapPath(FileName)); // Create the email attachment with the uploaded file System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(Server.MapPath(FileName)); // Attach the newly created email attachment obj.Attachments.Add(attach); // Store filename so we can delete it later //attach1 = strFileName; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)