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.
 

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

Top