Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

C# ASP.net attach file to email

Avatar of MangoMarcus
MangoMarcus asked on
6 Comments1 Solution1044 ViewsLast Modified:
II have an asp.net form with a FileUpload function. This section is working correctly:

protected void UploadCertificate(object sender, EventArgs e)
        if (quality_certificate.HasFile)
            string fileName = quality_certificate.FileName;
            quality_certificate.SaveAs(MapPath("fileuploads/" + fileName));
            LabelQC.Text = "File " + fileName + " has uploaded";
            LabelQC.Text = "No file uploaded";

However when I try to retreive this file on submitting the form, it will not attach to the email presumably because the MapPath line is incorrect? Any advice welcome!

Attachment attachFile = new Attachment(Server.MapPath("fileuploads/" + quality_certificate.FileName));

For example when its hard coded it works:

Attachment attachFile = new Attachment(Server.MapPath("fileuploads/logo.gif"));// THIS WORKS

The directory is fileuploads within the root of the web site.
Permissions set to 775.
identity impersonate="true"
Avatar of santanu30in
santanu30inFlag of India image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers