vinnie,
You don't. You should get the file from the Files collection exposed by
the Request property on your page. Then, you can use the InputStream that
is returned form the HttpPostedFile instance, and pass that to the
constructor of your Attachment instance.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
On Oct 8, 2:06 pm, "Nicholas Paldino [.NET/C# MVP]"
Vinnie,
You could just create instances of the Attachment class, passing in
the
InputStream property from the HttpPostedFile instance that corresponds
to
the uploaded file (which you get from the collection exposed by the
Files
property on the HttpRequest instance).
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi Nicholais, thanks for your help.
since it's my first time in writing a mail massege code, do you think
you can post a sample code that i can study and so apply to the form
i'm working on?
This is what's on the page:
To, From, Subject, Body of a mail message;
Upload-file field;
Submit button.
Thanks
What do you think about this:
/ get the name of the file, Upload is a control name
string fileName = Path.GetFileName(Upload.PostedFile.FileName);
Upload.PostedFile.SaveAs(@"C:\Website\" + fileName);
// then attach it
MailMessage msgMail = new MailMessage();
msgMail.Attachments.Add(new MailAttachment(@"C:\Website\" +
fileName));
Now, what happen if the webpage is on a ISP and not on my pc(is
published on internet)? how do i save the file on a virtual directory?