send file (upload) - asp

C

Cimento Cola

Hello all.
Hope anyone can help me!
I have this form, with:


Please choose your file: (browse)

The main purpose is the user to select a local file and then when he submits
a mail should be sent with that doc as attachment!
When the user submits i have a new asp from where the mail is sent. I´ve
defined all the propertys (like subject, from, to...) ok! (i use cdo.message
to send the mail)
My question is: how can i send as attachment the document the user submited?
Thank you for your time!
Regards.
 
M

MSDN

May want to use the .NET built in Mail

Sorry C# if you use VB.neT, below is VS.NET 2005 FW 2.0 and below it 1.1
This is incomplet but should get an idea.
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();

System.Net.Mail.Attachment ma = new
System.Net.Mail.Attachment("AttachmentFileName"); // if you saved it to HD

or

System.Net.Mail.Attachment ma2 = new
System.Net.Mail.Attachment("System.IO.Stream"); // if getting it directly
from memory

byte[] uploadedFile;

Request.Files[0].InputStream.Read(uploadedFile,0,Request.Files[0].ContentLength);

System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient("host");

or

System.Net.Mail.SmtpClient sc2 = new System.Net.Mail.SmtpClient("host",
"port");

// Set up From, To, Subject, Body, Encoding etc.. etc... etc... then Send
Message

sc.Send(mm);

// Depricated this is the old way of doing it. VS.NET 2003 FW 1.1

System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();

System.Web.Mail.SmtpMail = "smtpmail";

System.Web.Mail.MailAttachment ma = new
System.Web.Mail.MailAttachment("AttachmentFileName");

mm.Attachments.Add(ma);

System.Web.Mail.SmtpMail.Send(mmx);

SA
 
M

MSDN

Sorry I did not see ASP and not ASP.NET.

SA


MSDN said:
May want to use the .NET built in Mail

Sorry C# if you use VB.neT, below is VS.NET 2005 FW 2.0 and below it 1.1
This is incomplet but should get an idea.
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();

System.Net.Mail.Attachment ma = new
System.Net.Mail.Attachment("AttachmentFileName"); // if you saved it to HD

or

System.Net.Mail.Attachment ma2 = new
System.Net.Mail.Attachment("System.IO.Stream"); // if getting it directly
from memory

byte[] uploadedFile;

Request.Files[0].InputStream.Read(uploadedFile,0,Request.Files[0].ContentLength);

System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient("host");

or

System.Net.Mail.SmtpClient sc2 = new System.Net.Mail.SmtpClient("host",
"port");

// Set up From, To, Subject, Body, Encoding etc.. etc... etc... then Send
Message

sc.Send(mm);

// Depricated this is the old way of doing it. VS.NET 2003 FW 1.1

System.Web.Mail.MailMessage mm = new System.Web.Mail.MailMessage();

System.Web.Mail.SmtpMail = "smtpmail";

System.Web.Mail.MailAttachment ma = new
System.Web.Mail.MailAttachment("AttachmentFileName");

mm.Attachments.Add(ma);

System.Web.Mail.SmtpMail.Send(mmx);

SA



Cimento Cola said:
Hello all.
Hope anyone can help me!
I have this form, with:


Please choose your file: (browse)

The main purpose is the user to select a local file and then when he
submits a mail should be sent with that doc as attachment!
When the user submits i have a new asp from where the mail is sent. I´ve
defined all the propertys (like subject, from, to...) ok! (i use
cdo.message to send the mail)
My question is: how can i send as attachment the document the user
submited?
Thank you for your time!
Regards.
 
Joined
Jul 25, 2008
Messages
2
Reaction score
0
plz .. i want to attach files to mail..
but my fileupload embedded in wizard control.and it work on my local computer..but on the server gives me an error of "disposed stream or closed file ".although that im configuring the timeout and everything in Web.config.
i appreciate any help
 
Joined
Jul 25, 2008
Messages
2
Reaction score
0
FileUpload embeded in Wizard Control

hi;8)
im using FileUpload.PostedFile.InputStream to get the attachments
The FileUpload control is in step of the Wizard control steps.
I need to attach without saving files at server.
every thing works on local.
but when i upload my site. the sending fails,although im configuring web.config for uploading files.

i appreciate any help :loo:
 

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,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top