FileUpload and mail sending

  • Thread starter Thread starter Qweertz
  • Start date Start date
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);
 
You'll probably have to save the uploaded file to your filesystem and attach
the saved file. Use PostedFile.SaveAs.
 
You'll probably have to save the uploaded file to your filesystem and
attach the saved file. Use PostedFile.SaveAs.

Thanks, I'll try this way.
 

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

Back
Top