Hi all,
Has anyone run into this issue before?
My company uses database mail extensively for alerting and the like, and most emails sent have attachments. We've put in place procedures for removing emails older than a month from the MSDB database, however we've now had a client server completely run out of the disk space due to attachments being stored in the C:\Documents and Settings\User\Local Settings\Temp folder!?!
When I check the sysmail_delete_mailitems_sp sproc, it only removes entries in the MSDB tables, and doesn't remove these temporary files in the temp directory.
Does anyone know why SQL Server stores them in the temp directory of the service account user, as well as how we can remove them (apart from manually deleting the files), as we need to have an automated process for cleaning up emails, and at the moment SQL Server 2005 doesn't handle this very well.
I've checked this on our test server as well, and we're getting the same there, and this server is running the latest SP2 + hot fixes.
Thanks,
Reece.
It happens because when you attach a file to an email, the email system makes a copy of the file to attach -so that if the file is in use, or even deleted, the email attachment will send without error.
However, then temp folder is not being cleared -normally that happens when the user logs out. Since the mail account belongs to a service account, it is not logging out.
You may wish to create a SQL Agent job (or a Windows Scheduler task) to run daily and delete files older than one day.
|||Thanks for the info. We're in the process of testing a job to remove the files, but it would be definitely nice if SQL Server cleaned up these files itself when it does the DB Mail cleanup on the database.
Cheers,
Reece.
No comments:
Post a Comment