I have a listener that processes emails in the inetpub/mailroot/Queue
directory. Once the listener is done processing an email it proceeds to move the email to another directory. However, moving the email is not possible due to a file lock by the process inetinfo.exe
. I have noticed that this file lock is released after a period time that ranges from several hours to several days. You can see that the Queue
directory can get pretty full over time.
The only way I have been able to work around this is by manually stopping and starting my SMTP virtual server in IIS.
Is it possible to release this file lock programmatically? If not, is it possible to expedite releasing this file lock?
UPDATE
The listener monitors the Queue
folder for incoming emails and then processes them. Data from the emails is then inserted into an internal program of ours. After the listener is done with the email it moves the email to a success or fail directory elsewhere.
SOLVED
After coming back to this problem almost a year later I was finally able to solve it! The solution was to configure the SMTP Virtual Server's local (default) domain and set it to the appropriate domain of the emails I wanted to process. This caused emails to go into the Drop
folder where they could be freely manipulated without having to worry about process locks.
The "Queue" directory is meant for internal use by the SMTP server process. You're finding files locked there because you're not supposed to be working with them there. If your "Queue" directory is filling up then you'd be best-served to figure out why email deliveries are failing. It's unclear to me if the old SMTPDiag tool from Microsoft might work on Windows Server 2008, but it would be a place to start.
Update:
It's unclear to me exactly what you're trying to do with your processing task. The "Queue" folder is used to hold messages that are pending delivery. Messages that have are accepted for local delivery are stored in the "Drop" folder. Assuming you're looking for messages that are being accepted for local delivery I'd be concerned about why they're hanging out in "Queue" and not ending up in "Drop". There shouldn't be files building up in "Queue" unless something isn't working right.
(As an aside: Finding documentation re: the SMTP Service in Windows Server 2008 is turning out to be pretty difficult. The SMTP Service always has been a bit of an orphan, living in a netherworld between the Windows OS and Exchange. >sigh<)
there are some parameters in the registry to control the lock timings...
but to keep it easy...
Just restart IIS (as as scheduled task every 'n' minutes), if you are using IIS 7.0 do it this way...