Frustrating attachment error!!

Nicholasp27

New member
Joined
Aug 22, 2004
Messages
2
Programming Experience
3-5
Ok, so i'm doing vb.net web page and i am sending an email via smtp. All works fine. Then i added an html control for file dialog and it works fine if i choose say "c:\test.doc"

however, if i choose say "c:\documents and settings\desktop\Nicholasp27\test.doc" then it gives an "invalid mail attachment" error!

basically, if there is a space in the file path, it won't work...if no spaces, works fine

please help!!

something like this:

Dim mailAttachment As Mail.MailAttachment
Try
mailAttachment = New Mail.MailAttachment("c:\Test Document.txt")
email.Attachments.Add(mailAttachment)
System.Web.Mail.SmtpMail.SmtpServer = "smtp.servername.com"
System.Web.Mail.SmtpMail.Send(email)
 
Last edited:
ok, u have to upload the file to the server first...

Dim file1 As String = System.IO.Path.Combine(System.IO.Path.GetTempPath, System.IO.Path.GetFileName(dialog1.Value))

dialog1.PostedFile().SaveAs(file1)

mailattachment1= new mail.mailattachment(file1)
 
Last edited:
Back
Top