472,127 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

send file (upload) - asp

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.
Apr 19 '06 #1
2 2864
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" <ci*********@sexmagnet.com> wrote in message
news:u$**************@TK2MSFTNGP04.phx.gbl...
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.

Apr 19 '06 #2
Sorry I did not see ASP and not ASP.NET.

SA
"MSDN" <sq**********@hotmail.com> wrote in message
news:Oi**************@TK2MSFTNGP03.phx.gbl...
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" <ci*********@sexmagnet.com> wrote in message
news:u$**************@TK2MSFTNGP04.phx.gbl...
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.


Apr 19 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Ruben Duarte | last post: by
2 posts views Thread by Fatih BOY | last post: by
4 posts views Thread by Evgeny Zoldin | last post: by
1 post views Thread by Sam | last post: by
9 posts views Thread by eswanson | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.