Friday, March 18, 2011

Not be able to delete physical file from disk after attaching it to mail message

I had a problem in delteing a file after attaching it to mailmesasge object in c #, here is the code sample

MailMessage mailmesage = new MailMessage();



I even tried to close the file object usfine file.close and fileobject.dispose() but I am having still issue to delte the file and got this error.

Then I probed the issue in detail and came to know that I have to dispose the mailmessageobject like