It sounds like the problem is that you have a class handling I/O on the file that is open when the error occurs.
You need to cleanup things before you try to delete the file. Put calls to .Close() methods and such in the finally block of the t/c/f and do the file deletion after that (could be in the finally{} as well). That way, even if the mail process fails, everything else will still happen without problems.
Also, you could wrap the mailing portion of the code in its own t/c/f.
-
Peter