Avatar of shelbyinfotech

asked on 

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

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.
.NET Programming

Avatar of undefined
Last Comment

8/22/2022 - Mon