troubleshooting Question

Adding an attachment to email from upload httppostedfile.

Avatar of shelbyinfotech
shelbyinfotech asked on
.NET Programming
6 Comments2 Solutions340 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.

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

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros