On Oct 8, 8:09 pm, Vinnie <centro.ga...@gmail.com> wrote:
> On Oct 8, 2:02 pm, Alexey Smirnov <alexey.smir...@gmail.com> wrote:
>
>
>
> > MailMessage msgMail = new MailMessage();
> > msgMail.Attachments.Add(new MailAttachment("c:\\temp\\annual-
> > report.pdf"));
>
> hi Alexey thanks,
> but how do i relate this attachment to the mail that the user is now
> sending me?
> I mean, if on a webpage there is a form to send an email message to
> the webmaster, and is available the option to upload a file and attach
> it to this mail, how can this should be coded? (because if the user
> upload a file, i don't know the name of that file)
>
> Thanks
it's pretty easy, you save the file and attach to a message
For example (c#):
// 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));
.....
Look at the following article, I think it does more or less the same
thing
http://www.codeproject.com/useritems...pplication.asp