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

Adding an attachment to email vb.net from upload httppostedfile.

Avatar of shelbyinfotech
shelbyinfotech asked on
.NET Programming
6 Comments1 Solution340 ViewsLast Modified:
I am currently taking the uploaded file and saving it to disk.  Then, I attach it to an email.  This works however, sometimes, (inconsistent) it claims the file is in use by another process and won't save it to disk.  I had the bright idea that I could attach the filestream directly to  the mailmessage.attachment.add. I have not been able to get this to work.  I actually succeeded but the file that was attached had nothing in it.  It had the right name though. The command I tried was:

mailmessage.attachments.add(new attachment(uploadname.postedfile.inputstream, uploadname.postedfile.filename))

Any ideas? I've found lots of stuff about how to save the file to disk and then attach that but I'm trying to get away from that.
Avatar of shelbyinfotech

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