Email Attachment from Web Page (without saving to HD)

G

Guest

Is it possible to upload a document (from asp.net page file upload control)
and attach to an email message without saving to the hard drive?

thx
dave
 
S

S. Justin Gengo

Dave,

In Visual Studio 2005 that is now possible. In 2003 it is not (I believe).

Sincerely,

--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
G

Guest

Do you have any tips? I have searched the web and have yet to see one example
where the uploaded file was not saved to disk first (prior to attaching to an
email)

Any clues would be appreciated.
thx
 
S

S. Justin Gengo

Dave,

In Visual Studio 2005 you just have to add two lines to the normal email
code snippet (assuming you already have the file as a System.IO.Stream):

Dim message As New MailMessage("sender@address", "from@address", "Subject",
"Message Text")

Dim ItemAttached As New System.Net.Mail.Attachment(contentStream As
System.IO.Stream, Name)

message.Attachments.Add(ItemAttached)

Dim emailClient As New SmtpClient("Email Server Name")

emailClient.Send(message)


Regards,

--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top