No,
None of the formats worked for me.
more over I'm getting the full path of the file name in a variable and passing that as the attachment. I do not know how many subdirectories will be there ?
Thanks
Anitha
Main Topics
Browse All TopicsHi,
I'm trying to send some files as attachments to Email. When I send the file name as @"C:\Myfile.txt" the Email works fine.
But If i try to send a file @"C:\Documents and setings\my documents\sample.txt"
I get a message "Invalid mail attachment" .
How to fix this problem.
I also would like to know how to send mutiple mail attachments?
This is very urgent
Anitha
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
You did not answer my question: In which context are you trying to send the attachments?
an smtp mail client?
a webmail?
a webserver scripting language (PHP, ASP or other)?
a program you wrote yourself?
> I'm getting the full path of the file name in a variable.
That does not mean you cannot transform it. But that means that 8.3-names won't work.
Hi maUru,
Sorry about that.
Actually I was trying to upload an attachment without saving to a hard disk or to a web server.
I was trying to Upload the file which was in a memory stream and passing that file name as attachment(C:\\Documents and settings\my documents\sample.txt) . This obviously throws Invalid mail attachment exception because , mail attachment may not accept the spacing between subdirectory( Documents and settings like that)
I forgot to use the PostedFile.SaveAs method which saves the attachments in a web server.
I'm creating a Temp Directory and save the Attachemnts in that folder . these files will be deleted once the mails are sent.
string strFileName =myFile.PostedFile.FileNam
string strFileName = System.IO.Path.GetFileName
string sPath= "C:\\TempUploadFiles";
// To Check if the Directory Exists//
if (!System.IO.Directory.Exis
{
DirectoryInfo dirInfo= Directory.CreateDirectory(
string strTempFilePath=dirInfo.Ge
myFile.PostedFile.SaveAs(s
System.Web.Mail.MailMessag
MailAttachment MyAttachment= new MailAttachment(strTempFile
mailMessage.Attachments.Ad
System.Web.Mail.SmtpMail.S
System.IO.File.Delete(strT
}
Thanks
Anitha
Business Accounts
Answer for Membership
by: GrandSchtroumpfPosted on 2005-05-19 at 14:15:28ID: 14040687
In which context are you trying to send the attachments?
ings/my%20 documents/ sample.txt "
an smtp mail client?
a webmail?
a webserver scripting language (PHP, ASP or other)?
a program you wrote yourself?
Try one of these:
@'"C:\Documents and setings\my documents\sample.txt"'
@"'C:\Documents and setings\my documents\sample.txt'"
@"C:/Documents%20and%20set
(note the difference between single and double quotes)
you can always use the short 8.3 names, but that wont be a generic solution.