FileUpload and mail sending

Q

Qweertz

I'm trying to send e-mail with attachment that I take from FileUpload
control.
The problem is how to get full path of file.
For instance when I have file "C:\test.txt" FileUpload1.PostedFile.FileName
gets only "test.txt" and sending mail fails.

Can someone help?


Here's the code:

MailMessage mail = new MailMessage();
mail.From = "(e-mail address removed)";
mail.To = txtEmail.Text;
mail.Subject = "Anouncment about new Contract";
mail.Body = "Siging code is :" + txtSigningCode.Text;
mail.BodyFormat = MailFormat.Text;
mail.Attachments.Add(new MailAttachment(FileUpload2.PostedFile.FileName));
SmtpMail.Send(mail);
 
A

Aidy

You'll probably have to save the uploaded file to your filesystem and attach
the saved file. Use PostedFile.SaveAs.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top